Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: gdb-patches@sourceware.org
Subject: [PATCH] varobj.c
Date: Wed, 14 Feb 2007 23:06:00 -0000	[thread overview]
Message-ID: <17875.38347.137214.962583@kahikatea.snap.net.nz> (raw)


Following Denis' patch, this patch makes GDB throw a user error if a non
root variable is used for -var-update.  Currently GDB does:

(gdb)
-var-update var1.1
^done,changelist=[{name="var1.1",in_scope="false"}]
(gdb)

even though the expression that var1.1 represents may be inscope and have
changed value.

with this change:

(gdb)
-var-update var1.1
&"Only root variables can be updated\n"
^error,msg="Only root variables can be updated"
(gdb)

It also uses an assert if changelist is NULL.  I'm not sure how changelist
could be NULL, but if it is GDB has really lost the plot.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


2007-02-15  Nick Roberts  <nickrob@snap.net.nz>

	* varobj.c (varobj_update): Remove unused local.  Use gdb_assert
	to check changelist is non-NULL.  Call error if the frontend tries
	to update a non-root variable.

	* varobj.h (enum varobj_update_error): Delete WRONG_PARAM value.


*** varobj.h	13 Feb 2007 21:31:43 +1300	1.8
--- varobj.h	15 Feb 2007 11:38:47 +1300	
*************** enum varobj_update_error
*** 45,51 ****
      NOT_IN_SCOPE = -1,          /* varobj not in scope, can not be updated.  */
      TYPE_CHANGED = -2,          /* varobj type has changed.  */
      INVALID = -3,               /* varobj is not valid anymore.  */
-     WRONG_PARAM = -4            /* function is called with wrong arguments.  */
    };
  
  /* String representations of gdb's format codes (defined in varobj.c) */
--- 45,50 ----
*** varobj.c	13 Feb 2007 21:31:43 +1300	1.84
--- varobj.c	15 Feb 2007 11:46:07 +1300	
*************** int
*** 1037,1043 ****
  varobj_update (struct varobj **varp, struct varobj ***changelist)
  {
    int changed = 0;
-   int error = 0;
    int type_changed;
    int i;
    int vleft;
--- 1037,1042 ----
*************** varobj_update (struct varobj **varp, str
*** 1051,1063 ****
    struct frame_info *fi;
  
    /* sanity check: have we been passed a pointer?  */
!   if (changelist == NULL)
!     return WRONG_PARAM;
  
-   /*  Only root variables can be updated...  */
    if (!is_root_p (*varp))
!     /* Not a root var.  */
!     return WRONG_PARAM;
  
    if (!(*varp)->root->is_valid)
      return INVALID;
--- 1050,1059 ----
    struct frame_info *fi;
  
    /* sanity check: have we been passed a pointer?  */
!   gdb_assert (changelist);
  
    if (!is_root_p (*varp))
!     error (_("Only root variables can be updated"));
  
    if (!(*varp)->root->is_valid)
      return INVALID;


             reply	other threads:[~2007-02-14 23:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-14 23:06 Nick Roberts [this message]
2007-02-27 17:04 ` Daniel Jacobowitz
2007-02-28  6:36   ` Vladimir Prus

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=17875.38347.137214.962583@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --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