From patchwork Fri Mar 10 14:55:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66220 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A978385559A for ; Fri, 10 Mar 2023 14:57:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A978385559A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678460239; bh=pZrFZLWSxRZq6ZOmgxqHbFUOyxGfuKCFCgSPqnEcbLI=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=mMExT4df9i8c3H6UJ0GJ+xOhMF37OTfO7rSpkNs9+GSQRGNl37pjHDZNW0b5JMQqk 4ezU7ChAxIv+y5amPgz2tZiRHuYImPaAPHJC9ctxJrbOB14WsPbOuIv7rBtLPQGTgk 9ilQRFR9AhrNIo1SsufmlSTn8ZmcdKep1SDKTXGc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 65BF1385840D for ; Fri, 10 Mar 2023 14:56:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 65BF1385840D Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-scvPblTcMimFmT1dkvoQtw-1; Fri, 10 Mar 2023 09:56:01 -0500 X-MC-Unique: scvPblTcMimFmT1dkvoQtw-1 Received: by mail-wr1-f72.google.com with SMTP id a7-20020a056000188700b002cdd0562b11so1119280wri.11 for ; Fri, 10 Mar 2023 06:56:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678460160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pZrFZLWSxRZq6ZOmgxqHbFUOyxGfuKCFCgSPqnEcbLI=; b=yAZHE9G7cg3j4RPKXHe/Jm9/tsIk4Dx5qL2BH+B4oyni8uEXfyszSsAUH/NS+bj768 x4xLOa3e9r3aN0YV6Cz5oqrdbFc0vjetv55uvPlhNFFNsoIQSjqj+ZcRzG8SuOth4jGA W+lom5TdyDBo9I0crzfNGu3jDvN7IP0lSjKoQ1lmxhQwtPSHPaKFlGfbFA0tyr0u4u/k IJp3/xiQ9ODP7FKWAYOdc8iXpHC04hSRy3kksH4R/zX/Mo7L2Bg4NQllqvdHcXAA6w2K fuSn2mAnYRj6OS/gRNSG864KxXZl8oAUr6114i8JaAVJR2XL2VWTPH1DcJIRCYJpMXOL 2pBQ== X-Gm-Message-State: AO0yUKVz1WeQIJLVbW6fx2GuG9ZACnZumPebltWTmPcC9bgazCqear4b ZfYaLz1xzZGDoa2KAaKRWl/1xtlyq6rE683c3L9xP2lS5keHMyhX2M/1IJJ03AQmWGSqMN7ZPmc hzbsv6lwaJ2Jor96pHEpNtUaM+/+5+aU9oxEbQ/ji0wIFmSfhgfSNz8dFtVMNYt/8pz5fJ9cnkz 2fRof9oQ== X-Received: by 2002:a5d:4751:0:b0:2c5:76bd:c0f3 with SMTP id o17-20020a5d4751000000b002c576bdc0f3mr17963568wrs.6.1678460160648; Fri, 10 Mar 2023 06:56:00 -0800 (PST) X-Google-Smtp-Source: AK7set83mSL4HyxYhG+pCrvcbbi31Ddz65pPENMFWjL6v82HxHtt3I7GPH0z5NmAWXy0lMxov6yKhw== X-Received: by 2002:a5d:4751:0:b0:2c5:76bd:c0f3 with SMTP id o17-20020a5d4751000000b002c576bdc0f3mr17963553wrs.6.1678460160302; Fri, 10 Mar 2023 06:56:00 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id c16-20020adffb50000000b002c5544b3a69sm2365922wrs.89.2023.03.10.06.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 06:56:00 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 08/10] gdb: have value_as_address call unpack_pointer Date: Fri, 10 Mar 2023 14:55:25 +0000 Message-Id: <312bba523f1d5701df37f3c7984c1b18fc4b5f9d.1678460067.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" While refactoring some other code in gdb/python/* I wanted to merge two code paths. One path calls value_as_address, while the other calls unpack_pointer. I suspect calling value_as_address is the correct choice, but, while examining the code I noticed that value_as_address calls unpack_long rather than unpack_pointer. Under the hood, unpack_pointer does just call unpack_long so there's no real difference here, but it feels like value_as_address should call unpack_pointer. I've updated the code to use unpack_pointer, and changed a related comment to say that we call unpack_pointer. I've also adjusted the header comment on value_as_address. The existing header refers to some code that is now commented out. Rather than trying to describe the whole algorithm of value_as_address, which is already well commented within the function, I've just trimmed the comment on value_as_address to be a brief summary of what the function does. There should be no user visible changes after this commit. --- gdb/value.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 7b4df338304..d432b29b61b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2551,9 +2551,8 @@ value_as_long (struct value *val) return unpack_long (val->type (), val->contents ().data ()); } -/* Extract a value as a C pointer. Does not deallocate the value. - Note that val's type may not actually be a pointer; value_as_long - handles all the cases. */ +/* Extract a value as a C pointer. Does not deallocate the value. */ + CORE_ADDR value_as_address (struct value *val) { @@ -2592,7 +2591,7 @@ value_as_address (struct value *val) to COERCE_ARRAY below actually does all the usual unary conversions, which includes converting values of type `function' to `pointer to function'. This is the challenging conversion - discussed above. Then, `unpack_long' will convert that pointer + discussed above. Then, `unpack_pointer' will convert that pointer back into an address. So, suppose the user types `disassemble foo' on an architecture @@ -2653,7 +2652,7 @@ value_as_address (struct value *val) return gdbarch_integer_to_address (gdbarch, val->type (), val->contents ().data ()); - return unpack_long (val->type (), val->contents ().data ()); + return unpack_pointer (val->type (), val->contents ().data ()); #endif }