From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29730 invoked by alias); 24 Nov 2008 20:11:18 -0000 Received: (qmail 29654 invoked by uid 22791); 24 Nov 2008 20:11:16 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Nov 2008 20:10:28 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mAOKAGfi005133; Mon, 24 Nov 2008 15:10:16 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAOKAFY0030103; Mon, 24 Nov 2008 15:10:15 -0500 Received: from opsy.redhat.com (vpn-12-223.rdu.redhat.com [10.11.12.223]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mAOKAE5l002383; Mon, 24 Nov 2008 15:10:14 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id D4738378788; Mon, 24 Nov 2008 13:10:13 -0700 (MST) To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: RFA: move value_from_contents_and_address to value.c References: <20081122050546.GB4318@adacore.com> From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Mon, 24 Nov 2008 23:16:00 -0000 In-Reply-To: <20081122050546.GB4318@adacore.com> (Joel Brobecker's message of "Fri\, 21 Nov 2008 21\:05\:46 -0800") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2008-11/txt/msg00663.txt.bz2 >>>>> "Joel" == Joel Brobecker writes: Joel> I'm wondering whether the offset parameter is really necessary? Would it Joel> be worse to call this function with valaddr+embedded_offset rather Joel> than passing two arguments? Here is an updated patch which dispenses with this argument. Built and regtested on x86-64 (compile farm). Ok? Tom 2008-11-24 Tom Tromey * ada-lang.c (value_from_contents_and_address): Move... * value.c: ... here. * ada-lang.h (value_from_contents_and_address): Move declaration... * value.h: ... here. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f92d23b..d27416f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -465,26 +465,6 @@ is_suffix (const char *str, const char *suffix) return (len1 >= len2 && strcmp (str + len1 - len2, suffix) == 0); } -/* Create a value of type TYPE whose contents come from VALADDR, if it - is non-null, and whose memory address (in the inferior) is - ADDRESS. */ - -struct value * -value_from_contents_and_address (struct type *type, - const gdb_byte *valaddr, - CORE_ADDR address) -{ - struct value *v = allocate_value (type); - if (valaddr == NULL) - set_value_lazy (v, 1); - else - memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type)); - VALUE_ADDRESS (v) = address; - if (address != 0) - VALUE_LVAL (v) = lval_memory; - return v; -} - /* The contents of value VAL, treated as a value of type TYPE. The result is an lval in memory if VAL is. */ diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 562a867..440558c 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -257,10 +257,6 @@ extern int ada_value_print (struct value *, struct ui_file *, /* Defined in ada-lang.c */ -extern struct value *value_from_contents_and_address (struct type *, - const gdb_byte *, - CORE_ADDR); - extern void ada_emit_char (int, struct ui_file *, int, int); extern void ada_printchar (int, struct ui_file *); diff --git a/gdb/value.c b/gdb/value.c index 695aa33..03385f3 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1686,6 +1686,26 @@ value_from_string (char *ptr) return val; } +/* Create a value of type TYPE whose contents come from VALADDR, if it + is non-null, and whose memory address (in the inferior) is + ADDRESS. */ + +struct value * +value_from_contents_and_address (struct type *type, + const gdb_byte *valaddr, + CORE_ADDR address) +{ + struct value *v = allocate_value (type); + if (valaddr == NULL) + set_value_lazy (v, 1); + else + memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type)); + VALUE_ADDRESS (v) = address; + if (address != 0) + VALUE_LVAL (v) = lval_memory; + return v; +} + struct value * value_from_double (struct type *type, DOUBLEST num) { diff --git a/gdb/value.h b/gdb/value.h index 65fea99..3e924cc 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -289,6 +289,10 @@ extern struct value *value_from_string (char *string); extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); +extern struct value *value_from_contents_and_address (struct type *, + const gdb_byte *, + CORE_ADDR); + extern struct value *default_value_from_register (struct type *type, int regnum, struct frame_info *frame);