From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2981 invoked by alias); 12 Jul 2011 20:43:52 -0000 Received: (qmail 2961 invoked by uid 22791); 12 Jul 2011 20:43:50 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_DL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jul 2011 20:43:15 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6CKhFoh021946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Jul 2011 16:43:15 -0400 Received: from host1.jankratochvil.net ([10.3.113.13]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6CKhDo6004286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 12 Jul 2011 16:43:15 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p6CKhC6W000582 for ; Tue, 12 Jul 2011 22:43:12 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p6CKhBTU000581 for gdb-patches@sourceware.org; Tue, 12 Jul 2011 22:43:11 +0200 Date: Tue, 12 Jul 2011 21:09:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Code cleanup: Introduce allocate_optimized_out_value Message-ID: <20110712204311.GA324@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-07/txt/msg00324.txt.bz2 Hi, this is a code cleanup. Additionally it makes more optimized_out values lazy. IIRC I had some compatibility problems before with it but I no longer see any regressions, maybe since: [patch 1/2] Make values more lazy if possible http://sourceware.org/ml/gdb-patches/2011-01/msg00123.html or thanks to some other patch. allocate_optimized_out_value gets used more by my later entryval patch. No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu. I will check it in in some time if no comments appear. Thanks, Jan gdb/ 2011-07-12 Jan Kratochvil Code cleanup making also optimized out values lazy. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use allocate_optimized_out_value. Twice. (loclist_read_variable) Use allocate_optimized_out_value. Once. * findvar.c (read_var_value): Likewise. * value.c (allocate_optimized_out_value): New function. * value.h (allocate_optimized_out_value): New declaration. --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1094,12 +1094,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, invalid_synthetic_pointer (); if (size == 0) - { - retval = allocate_value (type); - VALUE_LVAL (retval) = not_lval; - set_value_optimized_out (retval, 1); - return retval; - } + return allocate_optimized_out_value (type); baton.frame = frame; baton.per_cu = per_cu; @@ -1247,9 +1242,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, case DWARF_VALUE_OPTIMIZED_OUT: do_cleanups (value_chain); - retval = allocate_value (type); - VALUE_LVAL (retval) = not_lval; - set_value_optimized_out (retval, 1); + retval = allocate_optimized_out_value (type); break; /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced @@ -2829,11 +2822,7 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame) data = dwarf2_find_location_expression (dlbaton, &size, pc); if (data == NULL) - { - val = allocate_value (SYMBOL_TYPE (symbol)); - VALUE_LVAL (val) = not_lval; - set_value_optimized_out (val, 1); - } + val = allocate_optimized_out_value (SYMBOL_TYPE (symbol)); else val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, data, size, dlbaton->per_cu); --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -577,10 +577,7 @@ read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_OPTIMIZED_OUT: - v = allocate_value_lazy (type); - VALUE_LVAL (v) = not_lval; - set_value_optimized_out (v, 1); - return v; + return allocate_optimized_out_value (type); default: error (_("Cannot look up value of a botched symbol.")); --- a/gdb/value.c +++ b/gdb/value.c @@ -728,6 +728,18 @@ allocate_computed_value (struct type *type, return v; } +/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ + +struct value * +allocate_optimized_out_value (struct type *type) +{ + struct value *retval = allocate_value_lazy (type); + + set_value_optimized_out (retval, 1); + + return retval; +} + /* Accessor methods. */ struct value * --- a/gdb/value.h +++ b/gdb/value.h @@ -207,6 +207,8 @@ extern struct value *allocate_computed_value (struct type *type, struct lval_funcs *funcs, void *closure); +extern struct value *allocate_optimized_out_value (struct type *type); + /* If VALUE is lval_computed, return its lval_funcs structure. */ extern struct lval_funcs *value_computed_funcs (struct value *value);