From patchwork Wed Apr 13 18:18:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunlian Jiang X-Patchwork-Id: 11736 Received: (qmail 92651 invoked by alias); 13 Apr 2016 18:18:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91530 invoked by uid 89); 13 Apr 2016 18:18:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2711, H*F:D*google.com X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 13 Apr 2016 18:18:20 +0000 Received: by mail-wm0-f42.google.com with SMTP id v188so188064626wme.1 for ; Wed, 13 Apr 2016 11:18:19 -0700 (PDT) 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:date :message-id:subject:from:to:cc; bh=045uudIxedc7JVkXeIkbkBaubIuNRTugnL5TMpQW4v4=; b=BYPFMdEGEaCWLu5rIscnXKIjkcBRgB1CaqTwumFv/m7S7rZuOiuEEBRGOW/tQKNabZ x+JF1oyjrVB4dk4dKWbIlzVCAqsjxV7KzdFWmRsXF+7vid5Q6xzDJQfiws2rz9r9yf5F 5UOkfzWorzFDO5L+5Fy4BCY6+e2K2VNvUPvggYLezOichFH/3NpClQ2xiZkoXxxMu9SD NICn8Zu6UxQEV/03W+GApjqvNnAzvFXtwp48V/0KSN4BT3SQzzOVxlQ4Nn2Hrv1yw++z OUw8hKU+qmuato6EkDR5Q3L54nA2fCVsz2AO6aFw0X7ymIG/FgnCEV95IyNOySba2HNx sq+Q== X-Gm-Message-State: AOPr4FWgce/PNh/dED8ywrh96yVqJgsrDPnzP3/rutfdEuCD6OzxNh4hp30i2q/UUdT35cqubX1kGSY4x7b7JVin MIME-Version: 1.0 X-Received: by 10.194.216.227 with SMTP id ot3mr12085488wjc.69.1460571497030; Wed, 13 Apr 2016 11:18:17 -0700 (PDT) Received: by 10.28.141.207 with HTTP; Wed, 13 Apr 2016 11:18:16 -0700 (PDT) In-Reply-To: <94eb2c0b782e20fcd6053001135e@google.com> References: <94eb2c0b782e20fcd6053001135e@google.com> Date: Wed, 13 Apr 2016 11:18:16 -0700 Message-ID: Subject: Re: [PATCH] fix PR gdb/19914 From: Yunlian Jiang To: Doug Evans Cc: gdb-patches@sourceware.org X-IsSubscribed: yes I have a updated one. It uses separate_debug_objfile_backlink to get the real dwp file name if it is a debug file. On Fri, Apr 8, 2016 at 3:54 PM, Doug Evans wrote: > Yunlian Jiang writes: > > Hi. > > > > This tries to fix PR gdb/19914. When the object file is not > > a binary but a .debug file, the function to try to find the .dwp > > file in the debug directory does not work. This one tries to solve > > this problem. > > > > 2016-04-05 Yunlian Jiang > > * gdb/dwarf2read.c: Try to find .dwp for .debug > > > > > > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > > index dcd49e3..551376a 100644 > > --- a/gdb/dwarf2read.c > > +++ b/gdb/dwarf2read.c > > @@ -10854,6 +10854,18 @@ open_and_init_dwp_file (void) > > dbfd = open_dwp_file (dwp_name); > > } > > > > + if (dbfd == NULL && strlen(dwp_name) > 10) > > + { > > + /* Try to find .dwp for the debug file. */ > > + if (!strcmp(dwp_name + strlen(dwp_name) - 10, ".debug.dwp")) > > + { > > + dwp_name[strlen(dwp_name) - 10] = '\0'; > > + dwp_name = xstrprintf ("%s.dwp", dwp_name); > > + make_cleanup (xfree, dwp_name); > > + dbfd = open_dwp_file (dwp_name); > > + } > > + } > > + > > if (dbfd == NULL) > > { > > if (dwarf_read_debug) > > Hi. > > I've looked at this a little bit. > I don't have time for a complete review at the moment, > but one thing I'm wondering about is whether this extra > test should go in open_dwp_file instead. > > Plus, while we're making the assumption that the separate debug > file ends with ".debug" that's not necessarily true. > Not sure we can do better, but one thought is to look in > separate_debug_objfile_backlink and use that. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -10835,13 +10835,28 @@ open_and_init_dwp_file (void) { struct objfile *objfile = dwarf2_per_objfile->objfile; struct dwp_file *dwp_file; + char *dwp_base_name; char *dwp_name; bfd *dbfd; struct cleanup *cleanups; /* Try to find first .dwp for the binary file before any symbolic links resolving. */ + + /* If the objfile is a debug file, find the name of the real binary + file and get the name of dwp file from there. */ + if (objfile->separate_debug_objfile_backlink) + { + dwp_base_name = xstrprintf ("%s.dwp", + lbasename (objfile->separate_debug_objfile_backlink->original_name)); + } + else + dwp_base_name = xstrprintf ("%s.dwp", lbasename (objfile->original_name)); + dwp_name = xstrprintf ("%s%s%s", ldirname(objfile->original_name), + SLASH_STRING, dwp_base_name); + dwp_name = xstrprintf ("%s.dwp", objfile->original_name); + cleanups = make_cleanup (xfree, dwp_base_name); cleanups = make_cleanup (xfree, dwp_name); dbfd = open_dwp_file (dwp_name);