From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94246 invoked by alias); 25 Jun 2017 17:24:41 -0000 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 Received: (qmail 94197 invoked by uid 89); 25 Jun 2017 17:24:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Jun 2017 17:24:18 +0000 Received: by simark.ca (Postfix, from userid 33) id 659741E5A1; Sun, 25 Jun 2017 13:24:06 -0400 (EDT) To: Simon Marchi Subject: Re: [PATCH] compile-loc2c: Fix uninitialized variable error X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 25 Jun 2017 17:24:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org, Tom Tromey In-Reply-To: <1497124148-11187-1-git-send-email-simon.marchi@ericsson.com> References: <1497124148-11187-1-git-send-email-simon.marchi@ericsson.com> Message-ID: <3ec2d2df8170bea2b43c095996ad7278@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00687.txt.bz2 On 2017-06-10 21:49, Simon Marchi wrote: > Compiling with clang gives this warning/error: > > /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:731:6: > error: variable 'uoffset' is uninitialized when used here > [-Werror,-Wuninitialized] > uoffset += dwarf2_per_cu_text_offset (per_cu); > ^~~~~~~ > /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:669:23: > note: initialize the variable 'uoffset' to silence this warning > uint64_t uoffset, reg; > ^ > = 0 > > I am really not sure if what this patch does is good, but it is my best > guess. DW_OP_addr means that there's an constant address provided by > the DWARF bytecode that should be pushed on the stack. That address is > considered skipped by the "op_ptr += addr_size", but it is never read. > uoffset is indeed read just after, without having been assigned first. > > So I think the intent is to read the address, it was just omitted. > > gdb/ChangeLog: > > * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Read > address when op is DW_OP_addr. > --- > gdb/compile/compile-loc2c.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c > index a53214f..ead1003 100644 > --- a/gdb/compile/compile-loc2c.c > +++ b/gdb/compile/compile-loc2c.c > @@ -722,6 +722,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file > &stream, > break; > > case DW_OP_addr: > + uoffset = extract_unsigned_integer (op_ptr, addr_size, byte_order); > op_ptr += addr_size; > /* Some versions of GCC emit DW_OP_addr before > DW_OP_GNU_push_tls_address. In this case the value is an Hi Tom, As you are the original author of that code, would it be possible for you to take a quick look, if you remember any of this :) ? Thanks, Simon