From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Fernando Nasser Cc: Michael Snyder , Fernando Nasser , Don Howard , gdb-patches@sources.redhat.com Subject: Re: [RFA] deleting breakpoints inside of 'commands' [Repost] Date: Wed, 19 Sep 2001 08:17:00 -0000 Message-id: <3BA8B70D.7040506@cygnus.com> References: <3BA67BAA.825A5957@cygnus.com> <3BA7519F.70E25EC3@redhat.com> <3BA7608F.3040104@cygnus.com> <3BA7859F.4F7ACFA2@cygnus.com> <3BA7EB28.7000502@cygnus.com> <3BA7EEED.B564DE2F@cygnus.com> <3BA8A8DC.717E8CE4@cygnus.com> X-SW-Source: 2001-09/msg00251.html > > I have the same concerns. > We haven't heard from Don yet. Maybe he has some compromise solution. > > Anyway, I find the copy solution a hack. > > One way to fix this is to have the chain of commands as an object with > use count. It is only freed when the count is down to zero again. > > When you associate it with a breakpoint it goes up to 1. When you > get it to execute it goes up to 2. > > When a breakpoint is deleted, it deallocates it. If the count goes > to zero memory is freed. But if the script is being executed (and > is deleting self) the count will go to 1 and nothing else happens > until the script finishes executing and the chain is freed (then > the count goes to zero and memory is deallocated). Rememeber, the patch doesn't have to be perfect, just acceptable. In this case, the change eliminates a stray pointer problem (which would likely still occure with reference counters) and hence makes gdb far more robust - I put robustness and maintainability at a much higher priority level then performance. When someone manages to demonstrate that the copy is a significant overhead (using ``set maint profile on/off'' [:-)]) then I think we should refine the code to do what you propose (or gasp add a garbage collector :-/). However, Don, if you're upto the task. Andrew