Message ID | 20200213053920.144599-1-tamur@google.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 117433 invoked by alias); 13 Feb 2020 05:39:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 117425 invoked by uid 89); 13 Feb 2020 05:39:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-pl1-f201.google.com Received: from mail-pl1-f201.google.com (HELO mail-pl1-f201.google.com) (209.85.214.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Feb 2020 05:39:30 +0000 Received: by mail-pl1-f201.google.com with SMTP id p19so2543431plr.8 for <gdb-patches@sourceware.org>; Wed, 12 Feb 2020 21:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=1D34sn/MHw1BY4vU9t7o59IwuB08GzbpcaKNS7ylcJ4=; b=h0FKi0V3yboK21tiL+hDdFaGcZq3UyLQtIY5XzDxZXuL1/OvApJSe0LOjoi567yQjz T/Tfl6Nygug9/9TXOjOjSIKakuK+sdpGulbKPeTFIVSES33IRAwEwzEN/F0lhPGDM8+A bHW7iHJ/kYTkjkZmRdtmHXjTTKD0G8SGcfN4sr/Le4OCNyE/QTk5rEjFicMoTYvFVe9M U7qmuYStFvhYSLTU54a0K30UxPTOZg3S2j6HFgSr9x0Oi/m/YMAyctsJGR6UAIQKnSI9 Ysqrp3y1m6nqXBRYdUMlYQhtHrlbnQtw72x/9h9ZcVgHVIiEAhZU3y9sIG1PoubDAjDo y3ew== Date: Wed, 12 Feb 2020 21:39:20 -0800 Message-Id: <20200213053920.144599-1-tamur@google.com> Mime-Version: 1.0 Subject: [PATCH] Fix off-by-one bug in dwarf 5 file indexes. From: "Ali Tamur via gdb-patches" <gdb-patches@sourceware.org> Reply-To: Ali Tamur <tamur@google.com> To: gdb-patches@sourceware.org Cc: Nitika.Achra@amd.com, JiniSusan.George@amd.com, Ali Tamur <tamur@google.com> Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes |
Commit Message
Terekhov, Mikhail via Gdb-patches
Feb. 13, 2020, 5:39 a.m. UTC
Fix dw2_get_file_names_reader behavior where it treated file names in line header as one indexed. gdb/ChangeLog: * dwarf2/read.c (dw2_get_file_names_reader): Bug fix. --- gdb/dwarf2/read.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Comments
>>>>> "Ali" == Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes:
Ali> Fix dw2_get_file_names_reader behavior where it treated file names in
Ali> line header as one indexed.
Ali> gdb/ChangeLog:
Ali> * dwarf2/read.c (dw2_get_file_names_reader): Bug fix.
Normally you should mention how the patch was tested. If it triggers
for some existing test, then you can just note that. Otherwise, it's
normal to add a new test, unless there's some reason that this is too
difficult.
thanks,
Tom
Hi, Sorry I have tried more than a day and I can neither find a test whose success depends solely on this change, nor was I able to construct one. It seems to me gdb is too resilient for small errors in debug sections. Current code ignores the first file name entry in the line header for dwarf 5, when constructing dwarf2_per_cu_data.v.quick.file_names: - Suppose the line header has two file name entries in m_file_names[0] and m_file_names[1]. A possible current code flow for the first iteration is: file_full_name(i + 1) => fule_file_name(1) => lh->file_name_at (1) => (because version >= 5) return &m_file_names[1]; So, m_file_names[0] is never used.. Can we apply the 'obvious rule' to submit this? Thanks, Ali On Thu, Feb 13, 2020 at 6:24 AM Tom Tromey <tom@tromey.com> wrote: > > >>>>> "Ali" == Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes: > > Ali> Fix dw2_get_file_names_reader behavior where it treated file names in > Ali> line header as one indexed. > > Ali> gdb/ChangeLog: > > Ali> * dwarf2/read.c (dw2_get_file_names_reader): Bug fix. > > Normally you should mention how the patch was tested. If it triggers > for some existing test, then you can just note that. Otherwise, it's > normal to add a new test, unless there's some reason that this is too > difficult. > > thanks, > Tom
On 2020-02-16 1:21 a.m., Ali Tamur via gdb-patches wrote: > Hi, > > Sorry I have tried more than a day and I can neither find a test whose > success depends solely on this change, nor was I able to construct > one. It seems to me gdb is too resilient for small errors in debug > sections. Current code ignores the first file name entry in the line > header for dwarf 5, when constructing > dwarf2_per_cu_data.v.quick.file_names: > - Suppose the line header has two file name entries in m_file_names[0] > and m_file_names[1]. A possible current code flow for the first > iteration is: > file_full_name(i + 1) => fule_file_name(1) => lh->file_name_at (1) => > (because version >= 5) return &m_file_names[1]; > So, m_file_names[0] is never used.. Can we apply the 'obvious rule' to > submit this? > > Thanks, > Ali Please describe what is the impact of the bug. I presume the consequence is that quick_file_names::file_names array will be not be constructed correctly? What does it contain in a gdb pre-your patch, and what does it contain in a gdb post-your patch? Already, it would help convince the reader (the human reader, not the dwarf reader) that there is indeed a bug an that your fix is right. If that array is not constructed correctly, then surely something will not work correctly down the line, like finding a symbol by file name or something like that? Unless the DWARF5 support of GDB is not evolved enough yet to get to the point where that array would be used? Simon
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7edbd9d7df..988d44a714 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3160,8 +3160,9 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader, XOBNEWVEC (&objfile->objfile_obstack, const char *, qfn->num_file_names); if (offset != 0) qfn->file_names[0] = xstrdup (fnd.name); + int index_offset = lh->version < 5 ? 1 : 0; for (int i = 0; i < lh->file_names_size (); ++i) - qfn->file_names[i + offset] = lh->file_full_name (i + 1, + qfn->file_names[i + offset] = lh->file_full_name (i + index_offset, fnd.comp_dir).release (); qfn->real_names = NULL;