From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18625 invoked by alias); 18 Apr 2014 19:06:20 -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 18546 invoked by uid 89); 18 Apr 2014 19:06:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 18 Apr 2014 19:06:18 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3B33011618B; Fri, 18 Apr 2014 15:06:16 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jcrORVQ-qmKJ; Fri, 18 Apr 2014 15:06:16 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 1138F116167; Fri, 18 Apr 2014 15:06:15 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id E8DFAE0851; Fri, 18 Apr 2014 12:06:23 -0700 (PDT) Date: Fri, 18 Apr 2014 19:06:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Sanimir Agovic Subject: Re: [PATCH 01/12] type: add c99 variable length array support Message-ID: <20140418190623.GA11447@adacore.com> References: <0377C58828D86C4588AEEC42FC3B85A71D8507B7@IRSMSX105.ger.corp.intel.com> <1397495596-25364-1-git-send-email-brobecker@adacore.com> <1397495596-25364-2-git-send-email-brobecker@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1397495596-25364-2-git-send-email-brobecker@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-04/txt/msg00385.txt.bz2 Hi Sanimir, (and dwarf2* experts!) Just looking through the code again, I found: > +/* Evaluates a dwarf expression and stores the result in VAL, expecting > + that the dwarf expression only produces a single CORE_ADDR. ADDR is a > + context (location of a variable) and might be needed to evaluate the > + location expression. > + Returns 1 on success, 0 otherwise. */ > + > +static int > +dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, > + CORE_ADDR addr, CORE_ADDR *valp) The "addr" parameter is unused in this case, and I am hoping that this would be normal. Re-reading location expressions, I don't see a lot of cases that could happen, and none of them see to require an address to start with). What do you think? The reason why I ended up looking at this code is because the current interface for resolving bounds needs an address. When you work from a value, there could be no address (Eg. if the value is inside a register, or its an lval_computed value). Currently, the interface works works with types (resolve_dynamic_type(type+addr)), but it would also be convenient to have a resolve_dynamic_value(value). If we can remove that address, then a number of simplifications can be made. I'll take care of all required updates, but I was wondering what your thoughts on this were... Thanks! > +{ > + struct dwarf_expr_context *ctx; > + struct dwarf_expr_baton baton; > + struct objfile *objfile; > + struct cleanup *cleanup; > + > + if (dlbaton == NULL || dlbaton->size == 0) > + return 0; > + > + ctx = new_dwarf_expr_context (); > + cleanup = make_cleanup_free_dwarf_expr_context (ctx); > + > + baton.frame = get_selected_frame (NULL); > + baton.per_cu = dlbaton->per_cu; > + > + objfile = dwarf2_per_cu_objfile (dlbaton->per_cu); > + > + ctx->gdbarch = get_objfile_arch (objfile); > + ctx->addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu); > + ctx->ref_addr_size = dwarf2_per_cu_ref_addr_size (dlbaton->per_cu); > + ctx->offset = dwarf2_per_cu_text_offset (dlbaton->per_cu); > + ctx->funcs = &dwarf_expr_ctx_funcs; > + ctx->baton = &baton; > + > + dwarf_expr_eval (ctx, dlbaton->data, dlbaton->size); > + > + switch (ctx->location) > + { > + case DWARF_VALUE_REGISTER: > + case DWARF_VALUE_MEMORY: > + case DWARF_VALUE_STACK: > + *valp = dwarf_expr_fetch_address (ctx, 0); > + if (ctx->location == DWARF_VALUE_REGISTER) > + *valp = dwarf_expr_read_addr_from_reg (&baton, *valp); > + do_cleanups (cleanup); > + return 1; > + case DWARF_VALUE_LITERAL: > + *valp = extract_signed_integer (ctx->data, ctx->len, > + gdbarch_byte_order (ctx->gdbarch)); > + do_cleanups (cleanup); > + return 1; > + /* Unsupported dwarf values. */ > + case DWARF_VALUE_OPTIMIZED_OUT: > + case DWARF_VALUE_IMPLICIT_POINTER: > + break; > + } > + > + do_cleanups (cleanup); > + return 0; -- Joel