From patchwork Thu Oct 27 13:55:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 16862 Received: (qmail 109553 invoked by alias); 27 Oct 2016 13:57:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 109492 invoked by uid 89); 27 Oct 2016 13:57:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Oct 2016 13:56:54 +0000 Received: by mail-pf0-f195.google.com with SMTP id n85so2747800pfi.3 for ; Thu, 27 Oct 2016 06:56:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=gMzp6DI3O4S4aYHQXSjMkyKnPAZoTkSPLb67ly107O8=; b=m1YwLxOEq9LdxmuZ32jI5pMh68BKgFQQLGiLVAhN9PCDY1HXykMEZB/m2/X4bktQie pYX7z7Sp6nyUBGmw06Lwp0gPA4KWFlBzOX+9t57255lphUt8lhMsql/KrX8yX/JNEygB tJBQcclifdDM5tcQXnm7DKhZTjfnZrpehlOBdCtJq1jj9xmKGL9wk0uVQsVztLFOWIQN Y/VOgQXPNd2UmkB8ZGPSbQzLDt7JAgknc1az3NelITn/n50C084Jb0Cq6xmH1n+ak1zF LUOKFOTh2n9sRs3wE07wm09EzVJfbZHSoxbRGVKAhtWgjrysFld+yJ5HqIu5OH8Gob2A 65Jg== X-Gm-Message-State: ABUngvftjLQCzWwEQ0mMwm9rr0ekOISyz9FE2w04QwG/YLAmzWcdKAf4BlAK6zBYWStxag== X-Received: by 10.98.202.156 with SMTP id y28mr14844727pfk.130.1477576609508; Thu, 27 Oct 2016 06:56:49 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id wc6sm12133796pab.47.2016.10.27.06.56.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Oct 2016 06:56:49 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Don't call value_address in x_command Date: Thu, 27 Oct 2016 14:55:59 +0100 Message-Id: <1477576559-28117-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes When I examine the usage of value_address and value_as_address in gdb code base, I happen to find that we can simplify the code in x_command a little bit. With this patch, we can get value address from value_as_address unconditionally. The code this patch removed was added in 1989, predates CVS repository, + * printcmd.c (x_command): Use variable itself rather + than treating it as a pointer only if it is a function. + (See comment "this makes x/i main work"). + /* In rvalue contexts, such as this, functions are coerced into + pointers to functions. This makes "x/i main" work. */ + if (/* last_format == 'i' + && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC + && VALUE_LVAL (val) == lval_memory) + next_address = VALUE_ADDRESS (val); + else + next_address = value_as_pointer (val); looks we don't need these special handling today because we record function address in value, so value_as_address can get the function address. Regression tested on x86_64-linux and ppc64-linux. gdb: 2016-10-27 Yao Qi * printcmd.c (x_command): Don't call value_address. --- gdb/printcmd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a256bed..67fd5a3 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1711,14 +1711,8 @@ x_command (char *exp, int from_tty) val = evaluate_expression (expr); if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF) val = coerce_ref (val); - /* In rvalue contexts, such as this, functions are coerced into - pointers to functions. This makes "x/i main" work. */ - if (/* last_format == 'i' && */ - TYPE_CODE (value_type (val)) == TYPE_CODE_FUNC - && VALUE_LVAL (val) == lval_memory) - next_address = value_address (val); - else - next_address = value_as_address (val); + + next_address = value_as_address (val); next_gdbarch = expr->gdbarch; do_cleanups (old_chain);