This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

make execute_control_command conform to docs


I've filed PR cli/1566 on this issue.  Also, I'm in the process of doing
the copyright assignment, but haven't yet completed it.  From lurking on
the list, it seems like two line patches aren't significant enough to be
a problem.  (I'm hoping.)

The attached patch makes two one-line changes to execute_control_command
in cli/cli-script.c to make it conform to the GDB internals
documentation section 13.1 on safely using cleanups.  Without the patch,
execute_control_command depends on the caller having done the right
thing by putting something on the cleanup_chain.  If
execute_control_command is called when cleanup_chain is null, the
cleanups execute_control_command puts on the chain are not removed, and
undefined behavior results.  

The patch makes execute_control_command safe by initializing old_chain
with a call to make_cleanup with a null_cleanup and always calling
do_cleanups before returning if anything other than the null_cleanup has
been put on the chain.  If the null_cleanup is the only thing put on the
chain, it could get left on it at return, but, as I read the code,
that's harmless.  The other possiblity would be to call do_cleanups at
every point we could return, but that seemed like more changes than were
necessary to fix the problem.  

Dave

Attachment: execute_control_command.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]