Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] New function value_has_address
Date: Tue, 22 Nov 2016 15:49:00 -0000	[thread overview]
Message-ID: <1479829721-22162-2-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1479829721-22162-1-git-send-email-yao.qi@linaro.org>

This patch is to move duplicated condition checking in three functions
to a single new function, value_has_address.

gdb:

2016-10-27  Yao Qi  <yao.qi@linaro.org>

	* value.c (value_has_address): New function.
	(value_address): Call value_has_address.
	(value_raw_address): Likewise.
	(set_value_address): Likewise.
---
 gdb/value.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/gdb/value.c b/gdb/value.c
index 8d33501..a8ab5db 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1540,12 +1540,20 @@ value_lval_const (const struct value *value)
   return value->lval;
 }
 
+/* Return true if VALUE has address, otherwise return false.  */
+
+static int
+value_has_address (const struct value *value)
+{
+  return (value->lval != lval_internalvar
+	  && value->lval != lval_internalvar_component
+	  && value->lval != lval_xcallable);
+}
+
 CORE_ADDR
 value_address (const struct value *value)
 {
-  if (value->lval == lval_internalvar
-      || value->lval == lval_internalvar_component
-      || value->lval == lval_xcallable)
+  if (!value_has_address (value))
     return 0;
   if (value->parent != NULL)
     return value_address (value->parent) + value->offset;
@@ -1561,9 +1569,7 @@ value_address (const struct value *value)
 CORE_ADDR
 value_raw_address (const struct value *value)
 {
-  if (value->lval == lval_internalvar
-      || value->lval == lval_internalvar_component
-      || value->lval == lval_xcallable)
+  if (!value_has_address (value))
     return 0;
   return value->location.address;
 }
@@ -1571,9 +1577,7 @@ value_raw_address (const struct value *value)
 void
 set_value_address (struct value *value, CORE_ADDR addr)
 {
-  gdb_assert (value->lval != lval_internalvar
-	      && value->lval != lval_internalvar_component
-	      && value->lval != lval_xcallable);
+  gdb_assert (value_has_address (value));
   value->location.address = addr;
 }
 
-- 
1.9.1


  parent reply	other threads:[~2016-11-22 15:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 15:49 [PATCH 0/3] " Yao Qi
2016-11-22 15:49 ` [PATCH 2/3] Set VALUE_VAL before set_value_address Yao Qi
2016-11-22 17:46   ` Luis Machado
2016-11-22 18:03   ` Pedro Alves
2016-11-22 15:49 ` [PATCH 3/3] Restrict value_has_address Yao Qi
2016-11-22 18:06   ` Pedro Alves
2016-11-22 15:49 ` Yao Qi [this message]
2016-11-22 16:50   ` [PATCH 1/3] New function value_has_address Joel Brobecker
2016-11-22 17:56     ` Pedro Alves
2016-11-22 18:16       ` Ulrich Weigand
2016-11-22 18:29         ` Pedro Alves
2016-11-23  9:26         ` Yao Qi
2016-11-23 12:50           ` Ulrich Weigand
2016-11-25 10:07             ` [PATCH 0/3] regnum and next_frame_id are only used for lval_register Yao Qi
2016-11-25 10:07               ` [PATCH 3/3] Restrict checking value.lval on using address Yao Qi
2016-11-25 11:52                 ` Ulrich Weigand
2016-11-28 17:22                   ` Yao Qi
2016-11-25 10:07               ` [PATCH 1/3] Move computed value's frame id to piece_closure Yao Qi
2016-11-25 11:48                 ` Ulrich Weigand
2016-11-28 17:20                   ` Yao Qi
2016-11-25 10:07               ` [PATCH 2/3] Adjust Value.location for lval_register Yao Qi
2016-11-25 11:51                 ` Ulrich Weigand
2016-11-25 11:57                   ` Yao Qi
2016-11-25 12:10                     ` Ulrich Weigand
2016-11-28 17:22                       ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479829721-22162-2-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox