Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: Nick Roberts <nickrob@snap.net.nz>, gdb-patches@sources.redhat.com
Subject: Re: [PATCH] MI: Free values when updating
Date: Tue, 23 Jan 2007 07:55:00 -0000	[thread overview]
Message-ID: <E1H9GUf-0004ji-UA@zigzag.lvk.cs.msu.su> (raw)
In-Reply-To: <17845.48393.877158.536969@kahikatea.snap.net.nz>

Nick Roberts wrote:

> The recent changes to varobj.c have resulted in values computed with
> -var-update not being freed automatically.  This makes computation longer
> and progressively so as currently free_all_values doesn't always get
> called.
> 
> Nick                                          
> http://www.inet.net.nz/~nickrob
> 
> 
> 2007-01-23  Nick Roberts  <nickrob@snap.net.nz>
> 
> * varobj.c (install_new_value): Don't call release_value when
> updating.
> 
> 
> *** varobj.c    16 Jan 2007 18:34:59 +1300      1.79
> --- varobj.c    23 Jan 2007 18:26:57 +1300
> *************** install_new_value (struct varobj *var, s
> *** 917,923 ****
> /* We are not interested in the address of references, and given
> that in C++ a reference is not rebindable, it cannot
> meaningfully change.  So, get hold of the real value.  */
> !   if (value)
> {
> value = coerce_ref (value);
> release_value (value);
> --- 917,923 ----
> /* We are not interested in the address of references, and given
> that in C++ a reference is not rebindable, it cannot
> meaningfully change.  So, get hold of the real value.  */
> !   if (initial && value)

I don't understand this change at all. It means that if you have 
a reference variable then:

        1. For initial value, dereferenced value will be saved
        2. For second and subsequent values, the value of reference itself will
        be saved. 

This is exactly what the code block in question tries to prevent --
it tries to make sure we always store dereferenced value.

When I try to run tests with this patch applied, I get:

Running ../.././gdb/testsuite/gdb.mi/mi-var-cmd.exp ...
ERROR: Couldn't send -var-create i  * i to GDB.
ERROR: Couldn't send -var-create l * l to GDB.
ERROR: Couldn't send -var-create linteger * linteger to GDB.

and many more errors like this. Did you run the testsuite after change?

Can you explain where the memory leak comes from. At the end of the function I see:

    if (var->value != NULL)
       value_free (var->value);

and the value passed to function itself does not have release_value called on it,
so should be freed automatically.

- Volodya



  reply	other threads:[~2007-01-23  7:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-23  7:45 Nick Roberts
2007-01-23  7:55 ` Vladimir Prus [this message]
2007-01-23  8:56   ` Nick Roberts
2007-01-23  9:15     ` Vladimir Prus
2007-01-23 11:02       ` Nick Roberts
2007-01-23 12:12         ` Daniel Jacobowitz
2007-01-23 21:19           ` Nick Roberts
2007-01-23 21:35             ` Vladimir Prus
2007-01-24  8:00         ` Vladimir Prus
2007-01-24  9:14           ` Nick Roberts
2007-01-24  9:21             ` 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=E1H9GUf-0004ji-UA@zigzag.lvk.cs.msu.su \
    --to=ghost@cs.msu.su \
    --cc=gdb-patches@sources.redhat.com \
    --cc=nickrob@snap.net.nz \
    /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