From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76985 invoked by alias); 29 Oct 2015 17:05:12 -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 76973 invoked by uid 89); 29 Oct 2015 17:05:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 29 Oct 2015 17:05:04 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4A333DA2; Thu, 29 Oct 2015 17:05:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9TH4rLt008852; Thu, 29 Oct 2015 13:04:57 -0400 Message-ID: <563251B4.5040408@redhat.com> Date: Thu, 29 Oct 2015 17:10:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH c++ 2/6] mdebugread.c: Add cast References: <1446123767-25046-1-git-send-email-simon.marchi@polymtl.ca> <1446123767-25046-3-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1446123767-25046-3-git-send-email-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2015-10/txt/msg00702.txt.bz2 On 10/29/2015 01:02 PM, Simon Marchi wrote: > I spent some time looking at the code trying to understand what happens. > I'm still not totally sure, but if it's been there all that time it must > be ok. If anybody wants to take a deeper look, please do. Ah, a challenge! Must ... resist ... How about this instead? From: Pedro Alves Subject: [PATCH] mdebugread.c: Address class -> address class index This fixes this error in C++ mode: /home/pedro/gdb/mygit/cxx-convertion/src/gdb/mdebugread.c:654:11: error: invalid conversion from ‘int’ to ‘address_class’ [-fpermissive] theclass = mdebug_register_index; ^ The "theclass" local is of type enum address_class, however, what it really holds is an address class index. Class index values by design match the address class values up until LOC_FINAL_VALUE, but extend beyond that, so it's not really right to store an address class index in an enum address_class. The fix is really the same as making the 'theclass' local be of type int, but while we're at it, we get rid of the goto, and thus the local becomes the 'aclass_index' parameter in the new add_data_symbol function. gdb/ChangeLog: 2015-10-29 Pedro Alves * mdebugread.c (add_data_symbol): New function, factored out from ... (parse_symbol): ... here. Delete 'theclass' local. --- gdb/mdebugread.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 03c1ff8..da5ec60 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -567,6 +567,26 @@ static const struct symbol_register_ops mdebug_register_funcs = { static int mdebug_register_index; static int mdebug_regparm_index; +/* Common code for symbols describing data. */ + +static int +add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend, + struct symbol *s, int aclass_index, struct block *b, + struct objfile *objfile, char *name) +{ + SYMBOL_DOMAIN (s) = VAR_DOMAIN; + SYMBOL_ACLASS_INDEX (s) = aclass_index; + add_symbol (s, top_stack->cur_st, b); + + /* Type could be missing if file is compiled without debugging info. */ + if (SC_IS_UNDEF (sh->sc) + || sh->sc == scNil || sh->index == indexNil) + SYMBOL_TYPE (s) = objfile_type (objfile)->nodebug_data_symbol; + else + SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name); + /* Value of a data symbol is its memory address. */ +} + static int parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, struct section_offsets *section_offsets, struct objfile *objfile) @@ -581,7 +601,6 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, struct type *t; struct field *f; int count = 1; - enum address_class theclass; TIR tir; long svalue = sh->value; int bitsize; @@ -622,15 +641,14 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, break; case stGlobal: /* External symbol, goes into global block. */ - theclass = LOC_STATIC; b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st), GLOBAL_BLOCK); s = new_symbol (name); SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; - goto data; + add_data_symbol (sh, ax, bigend, s, LOC_STATIC, b, objfile, name); + break; case stStatic: /* Static data, goes into current block. */ - theclass = LOC_STATIC; b = top_stack->cur_block; s = new_symbol (name); if (SC_IS_COMMON (sh->sc)) @@ -644,29 +662,19 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, } else SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; - goto data; + add_data_symbol (sh, ax, bigend, s, LOC_STATIC, b, objfile, name); + break; case stLocal: /* Local variable, goes into current block. */ b = top_stack->cur_block; s = new_symbol (name); SYMBOL_VALUE (s) = svalue; if (sh->sc == scRegister) - theclass = mdebug_register_index; - else - theclass = LOC_LOCAL; - - data: /* Common code for symbols describing data. */ - SYMBOL_DOMAIN (s) = VAR_DOMAIN; - SYMBOL_ACLASS_INDEX (s) = theclass; - add_symbol (s, top_stack->cur_st, b); - - /* Type could be missing if file is compiled without debugging info. */ - if (SC_IS_UNDEF (sh->sc) - || sh->sc == scNil || sh->index == indexNil) - SYMBOL_TYPE (s) = objfile_type (objfile)->nodebug_data_symbol; + add_data_symbol (sh, ax, bigend, s, mdebug_register_index, + b, objfile, name); else - SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name); - /* Value of a data symbol is its memory address. */ + add_data_symbol (sh, ax, bigend, s, LOC_LOCAL, + b, objfile, name); break; case stParam: /* Arg to procedure, goes into current -- 1.9.3