From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by sourceware.org (Postfix) with ESMTPS id 03F0F385BF81 for ; Thu, 9 Apr 2020 09:33:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 03F0F385BF81 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x341.google.com with SMTP id e26so3190936wmk.5 for ; Thu, 09 Apr 2020 02:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=51awWRwKyvhoqJTKtX9ENcPEVuxLDp8ydwH+XVJw8W4=; b=csT+iv8KfFVXhF6bL9+McbUQYLm/9IvrHYKzS/cbuvDLSHGTsEZya4Wlx8eK6DEnEb YPEmKGD1OmbA4n636xN8JgQvJrWKttdDPku+OLB4jZ9/Nra4C/dM1Vgyz9oGRR89YJsT nEj8MispuqIENH50xTjzKuc2zG6uXuovVjKiZxsKs0AZ/znjCFz/U5GQwrLry/+i3Ij3 slk1ettcBHAyA7La87lN/PAoM1NKnFqEDzzE8O1Si+C1ITGRlqrI2gzu1udxsuLEXKbh WNLY5E4s15lOVbR6E3hb3HSEWOMslX9kYZotScPHEREb9CP3k7KVlgFBpQIhNaeox6me koPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=51awWRwKyvhoqJTKtX9ENcPEVuxLDp8ydwH+XVJw8W4=; b=EOMOa2PakdsC6JUZeqervQBWwCNfyL02GHXn50EgYtImPlNHmSe/brmUA3xQ8yQKyx c/G1HC6D0poi4l7NY/t2tnptKTvYJa+hRCLB68+rubRTYq+otIpmXYY/C7lTgas7FFHr W/Lm9wPJOhIkAyEY3NdtjLg2wtpOkI+jZScDAdDZ0dpITrBrY5M1v2mER8rJietVfDLt IYVvufY81BMByxRQiAH1kYpf8a03dqpmzubXPENSRsohSTGEnAL8GSyIsHswc1X1gQ5w sovwPEaaWsVesjDV9msTWjS1yhhfp3kfJXMFR//CoryyZBby5r/0TTE27057/UD7d26s 2GSQ== X-Gm-Message-State: AGi0PuYTu9b3cRuQpjbctGYkLJVtopjQkofHW4mV9ORW8vXFyjaFK5Ub sa2w7bfhwSapVBzmKigBojwmdA== X-Google-Smtp-Source: APiQypJdPlZdsgGBlDuUtvptlsuOASTEfTSKXPmmAK80jejPSFFCGPz8RuBm18Yp6ImuTSw3p8uXjQ== X-Received: by 2002:a7b:c149:: with SMTP id z9mr8739352wmi.90.1586424806016; Thu, 09 Apr 2020 02:33:26 -0700 (PDT) Received: from localhost (host81-151-181-184.range81-151.btcentralplus.com. [81.151.181.184]) by smtp.gmail.com with ESMTPSA id 138sm3199401wmb.14.2020.04.09.02.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 02:33:25 -0700 (PDT) Date: Thu, 9 Apr 2020 10:33:24 +0100 From: Andrew Burgess To: Bernd Edlinger Cc: "gdb-patches@sourceware.org" , Tom Tromey Subject: Re: [PATCH] Partially revert my UB fix in record_line Message-ID: <20200409093324.GA2366@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.5.13-200.fc31.x86_64 (x86_64) X-Uptime: 10:32:40 up 1 day, 47 min, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-25.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2020 09:33:28 -0000 * Bernd Edlinger [2020-04-09 03:35:17 +0200]: > This reverts the following commit partially: > > commit 64dc2d4bd24ff7119c913fff91184414f09b8042 > Author: Bernd Edlinger > Date: Thu Mar 12 11:52:34 2020 +0100 > > Fix an undefined behavior in record_line > > Additionally do not completely remove symbols > at the same PC than the end marker, instead > make them non-is-stmt breakpoints. > > We keep the undefined behavoir fix, > but have to restore the original behavior > regarding deletion of the line entries. > > 2020-04-09 Bernd Edlinger > > revert partially: > 2020-04-01 Bernd Edlinger > > * buildsym.c (record_line): Fix undefined behavior and preserve > lines at eof. Looks good. Approved. Thanks, Andrew > --- > gdb/buildsym.c | 37 ++++++++++++++++++------------------- > 1 file changed, 18 insertions(+), 19 deletions(-) > > diff --git a/gdb/buildsym.c b/gdb/buildsym.c > index fe07103..c08c476 100644 > --- a/gdb/buildsym.c > +++ b/gdb/buildsym.c > @@ -691,29 +691,28 @@ struct blockvector * > * sizeof (struct linetable_entry)))); > } > > - /* The end of sequence marker is special. We need to reset the > - is_stmt flag on previous lines at the same PC, otherwise these > - lines may cause problems since they might be at the same address > - as the following function. For instance suppose a function calls > - abort there is no reason to emit a ret after that point (no joke). > - So the label may be at the same address where the following > - function begins. A similar problem appears if a label is at the > - same address where an inline function ends we cannot reliably tell > - if this is considered part of the inline function or the calling > - program or even the next inline function, so stack traces may > - give surprising results. Expect gdb.cp/step-and-next-inline.exp > - to fail if these lines are not modified here. */ > - if (line == 0 && subfile->line_vector->nitems > 0) > + /* Normally, we treat lines as unsorted. But the end of sequence > + marker is special. We sort line markers at the same PC by line > + number, so end of sequence markers (which have line == 0) appear > + first. This is right if the marker ends the previous function, > + and there is no padding before the next function. But it is > + wrong if the previous line was empty and we are now marking a > + switch to a different subfile. We must leave the end of sequence > + marker at the end of this group of lines, not sort the empty line > + to after the marker. The easiest way to accomplish this is to > + delete any empty lines from our table, if they are followed by > + end of sequence markers. All we lose is the ability to set > + breakpoints at some lines which contain no instructions > + anyway. */ > + if (line == 0) > { > - e = subfile->line_vector->item + subfile->line_vector->nitems; > - do > + while (subfile->line_vector->nitems > 0) > { > - e--; > - if (e->pc != pc || e->line == 0) > + e = subfile->line_vector->item + subfile->line_vector->nitems - 1; > + if (e->pc != pc) > break; > - e->is_stmt = 0; > + subfile->line_vector->nitems--; > } > - while (e > subfile->line_vector->item); > } > > e = subfile->line_vector->item + subfile->line_vector->nitems++; > -- > 1.9.1