[PATCH v2 3/3] gdb: Remove unused buffer_clearer variable.

Iain Buclaw ibuclaw@gdcproject.org
Sat Nov 30 09:57:00 GMT 2019


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, 30 November 2019 04:28, Simon Marchi <simark@simark.ca> wrote:

> On 2019-11-28 7:12 p.m., Iain Buclaw wrote:
>
> > When reviewing how fputs_maybe_unfiltered works, I noticed that the compiler was removing this variable and assigned lambda expression as dead code.
> > There are no early returns in this function, so release() is always called.
> > --
> > Iain
>
> The goal of this variable is to cleanup on scope exit, in the
> event an exception is raised, for instance by prompt_for_continue
> if the user presses q to stop the command. So it's normal that
> there is nothing using the variable directly.
>
> It would be alarming if the compiled was really optimizing this
> out. Can you give more details on how you reached that conclusion?
>

When initially stepping through this code to work out what this was doing, I noticed this variable was optimized out completely.  When compiling with -fdump-tree-optimized, I couldn't see at a glance any buffer_clearer nor lambda functions relating to fputs_maybe_filtered.

Maybe the scope_exit body got inlined somewhere and I missed it completely.  If this is expected to be lowered to a 'try{...} finally{...}' statement, I'm fine ignoring this.  It's not related to what I was trying to fix, this is just something that initially threw me off.


--
Iain




More information about the Gdb-patches mailing list