diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-04-07 14:03:12 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2018-04-07 14:03:12 -0400 |
commit | 6f14adc55864818ec3754460f5df4150c2addf42 (patch) | |
tree | 5ed8e7dccc5aeb3cc905394943a56fb21dddfaf9 /gdb/tracepoint.c | |
parent | b2bdb8cf395f491319264cda42e41538f55a86d9 (diff) | |
download | gdb-6f14adc55864818ec3754460f5df4150c2addf42.zip gdb-6f14adc55864818ec3754460f5df4150c2addf42.tar.gz gdb-6f14adc55864818ec3754460f5df4150c2addf42.tar.bz2 |
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.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index f66cc68..a2f1376 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3012,43 +3012,9 @@ set_current_traceframe (int num) clear_traceframe_info (); } -/* A cleanup used when switching away and back from tfind mode. */ - -struct current_traceframe_cleanup -{ - /* The traceframe we were inspecting. */ - int traceframe_number; -}; - -static void -do_restore_current_traceframe_cleanup (void *arg) -{ - struct current_traceframe_cleanup *old - = (struct current_traceframe_cleanup *) arg; - - set_current_traceframe (old->traceframe_number); -} - -static void -restore_current_traceframe_cleanup_dtor (void *arg) -{ - struct current_traceframe_cleanup *old - = (struct current_traceframe_cleanup *) arg; - - xfree (old); -} - -struct cleanup * -make_cleanup_restore_current_traceframe (void) -{ - struct current_traceframe_cleanup *old = - XNEW (struct current_traceframe_cleanup); - - old->traceframe_number = traceframe_number; - - return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old, - restore_current_traceframe_cleanup_dtor); -} +scoped_restore_current_traceframe::scoped_restore_current_traceframe () +: m_traceframe_number (traceframe_number) +{} /* Given a number and address, return an uploaded tracepoint with that number, creating if necessary. */ |