This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Dispose properly of registered gdbarch'es at exit.
- From: Tom Tromey <tromey at redhat dot com>
- To: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- Cc: <gdb-patches at sourceware dot org>
- Date: Tue, 11 Dec 2012 11:53:09 -0700
- Subject: Re: [RFC] Dispose properly of registered gdbarch'es at exit.
- References: <10150.4984115765$1355246247@news.gmane.org>
>>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr> writes:
Pierre> I am trying to get GDB to release all the allocated
Pierre> memory.
Pierre> Currently one of the biggest remaining chunk is the
Pierre> allocated gdbarch.
Pierre> The patch below is an attempt to get rid of that leak.
Thanks.
Pierre> PS: It might seem unimportant for GDB executable,
Pierre> but having a library that has no leak is useful...
Cough cough.
I think I would like it if "final" cleanups were only ones that were
important to gdb shutdown. There's no reason to do much shutdown work
if you're just going to exit.
I see a bogus-by-this-rule final cleanup in gdb_insn_length.
Anyway, I suppose you could introduce a new kind of cleanup that is only
used by your program.
Pierre> +static void
Pierre> +gdbarch_free_registered (void *arg)
Needs an intro comment.
Pierre> + struct gdbarch_registration *curr = *(struct gdbarch_registration **)arg;
Pierre> + gdb_assert (curr == gdbarch_registry);
Blank line between declaration and code.
The 'curr' thing is somewhat weird given the assert.
Personally I would just ignore the argument and use the global.
However, I don't mind the above; but you need a space after the closing
paren on the cast.
Pierre> + struct gdbarch_list *list = curr->arches;
Pierre> + while (list)
Blank line.
Pierre> + /* There is a gdb_assert on this inside gdbarch_free. */
Pierre> + list->gdbarch->initialized_p = 0;
I think at this point it is better to remove the assert, since it is no
longer correct.
Tom