Replace make_cleanup_restore_current_traceframe with RAII class

I put the constructor in tracepoint.c because it needs to read
traceframe_number, and I prefer to do that than to expose
traceframe_number.

gdb/ChangeLog:

	* tracepoint.c (struct current_traceframe_cleanup): Remove.
	(do_restore_current_traceframe_cleanup): Remove.
	(restore_current_traceframe_cleanup_dtor): Remove.
	(make_cleanup_restore_current_traceframe): Remove.
	(scoped_restore_current_traceframe::scoped_restore_current_traceframe):
	New.
	* tracepoint.h (struct scoped_restore_current_traceframe): New.
	* infrun.c (fetch_inferior_event): Use
	scoped_restore_current_traceframe.
This commit is contained in:
Simon Marchi
2018-04-07 14:03:12 -04:00
parent b2bdb8cf39
commit 6f14adc558
4 changed files with 33 additions and 39 deletions

View File

@ -321,7 +321,22 @@ extern int get_tracepoint_number (void);
etc.). */
extern void set_current_traceframe (int num);
struct cleanup *make_cleanup_restore_current_traceframe (void);
struct scoped_restore_current_traceframe
{
scoped_restore_current_traceframe ();
~scoped_restore_current_traceframe ()
{
set_current_traceframe (m_traceframe_number);
}
DISABLE_COPY_AND_ASSIGN (scoped_restore_current_traceframe);
private:
/* The traceframe we were inspecting. */
int m_traceframe_number;
};
void free_actions (struct breakpoint *);