From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/7] Garbage collect dummy_frame_ctx_saver
Date: Wed, 12 Aug 2015 17:11:00 -0000 [thread overview]
Message-ID: <1439398917-22761-6-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1439398917-22761-1-git-send-email-palves@redhat.com>
Since the "finish" command and infcall's FSMs are now responsible for
saving the return value, the dummy_frame_ctx_saver is no longer needed
anywhere.
gdb/ChangeLog:
2015-08-12 Pedro Alves <palves@redhat.com>
* infcall.c (struct dummy_frame_context_saver): Delete.
(dummy_frame_context_saver_free, dummy_frame_context_saver_dtor)
(dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs)
(dummy_frame_context_saver_setup): Delete.
* infcall.h (dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs, dummy_frame_context_saver):
Delete.
(get_return_value): Remove 'ctx_saver' paremeter. Adjust.
* inferior.h (get_return_value): Remove 'ctx_saver' paremeter.
* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Adjust.
---
gdb/infcall.c | 92 +---------------------------------------
gdb/infcall.h | 9 ----
gdb/infcmd.c | 19 +++------
gdb/inferior.h | 6 +--
gdb/python/py-finishbreakpoint.c | 5 +--
5 files changed, 10 insertions(+), 121 deletions(-)
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 5acdff0..e3df9f7 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "infcall.h"
#include "breakpoint.h"
#include "tracepoint.h"
#include "target.h"
@@ -30,7 +31,6 @@
#include "objfiles.h"
#include "gdbcmd.h"
#include "command.h"
-#include "infcall.h"
#include "dummy-frame.h"
#include "ada-lang.h"
#include "gdbthread.h"
@@ -661,96 +661,6 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
return call_function_by_hand_dummy (function, nargs, args, NULL, NULL);
}
-/* Data for dummy_frame_context_saver. Structure can be freed only
- after both dummy_frame_context_saver_dtor and
- dummy_frame_context_saver_drop have been called for it. */
-
-struct dummy_frame_context_saver
-{
- /* Inferior registers fetched before associated dummy_frame got freed
- and before any other destructors of associated dummy_frame got called.
- It is initialized to NULL. */
- struct regcache *retbuf;
-
- /* It is 1 if this dummy_frame_context_saver_drop has been already
- called. */
- int drop_done;
-};
-
-/* Free struct dummy_frame_context_saver. */
-
-static void
-dummy_frame_context_saver_free (struct dummy_frame_context_saver *saver)
-{
- regcache_xfree (saver->retbuf);
- xfree (saver);
-}
-
-/* Destructor for associated dummy_frame. */
-
-static void
-dummy_frame_context_saver_dtor (void *data_voidp, int registers_valid)
-{
- struct dummy_frame_context_saver *data = data_voidp;
-
- gdb_assert (data->retbuf == NULL);
-
- if (data->drop_done)
- dummy_frame_context_saver_free (data);
- else if (registers_valid)
- data->retbuf = regcache_dup (get_current_regcache ());
-}
-
-/* Caller is no longer interested in this
- struct dummy_frame_context_saver. After its associated dummy_frame
- gets freed struct dummy_frame_context_saver can be also freed. */
-
-void
-dummy_frame_context_saver_drop (struct dummy_frame_context_saver *saver)
-{
- saver->drop_done = 1;
-
- if (!find_dummy_frame_dtor (dummy_frame_context_saver_dtor, saver))
- dummy_frame_context_saver_free (saver);
-}
-
-/* Stub dummy_frame_context_saver_drop compatible with make_cleanup. */
-
-void
-dummy_frame_context_saver_cleanup (void *data)
-{
- struct dummy_frame_context_saver *saver = data;
-
- dummy_frame_context_saver_drop (saver);
-}
-
-/* Fetch RETBUF field of possibly opaque DTOR_DATA.
- RETBUF must not be NULL. */
-
-struct regcache *
-dummy_frame_context_saver_get_regs (struct dummy_frame_context_saver *saver)
-{
- gdb_assert (saver->retbuf != NULL);
- return saver->retbuf;
-}
-
-/* Register provider of inferior registers at the time DUMMY_ID frame of
- PTID gets freed (before inferior registers get restored to those
- before dummy_frame). */
-
-struct dummy_frame_context_saver *
-dummy_frame_context_saver_setup (struct frame_id dummy_id, ptid_t ptid)
-{
- struct dummy_frame_context_saver *saver;
-
- saver = xmalloc (sizeof (*saver));
- saver->retbuf = NULL;
- saver->drop_done = 0;
- register_dummy_frame_dtor (dummy_id, inferior_ptid,
- dummy_frame_context_saver_dtor, saver);
- return saver;
-}
-
/* All this stuff with a dummy frame may seem unnecessarily complicated
(why not just save registers in GDB?). The purpose of pushing a dummy
frame which looks just like a real frame is so that if you call a
diff --git a/gdb/infcall.h b/gdb/infcall.h
index 43b5f66..77c5101 100644
--- a/gdb/infcall.h
+++ b/gdb/infcall.h
@@ -50,13 +50,4 @@ extern struct value *
dummy_frame_dtor_ftype *dummy_dtor,
void *dummy_dtor_data);
-struct dummy_frame_context_saver;
-extern void dummy_frame_context_saver_drop
- (struct dummy_frame_context_saver *data);
-extern void dummy_frame_context_saver_cleanup (void *data_voidp);
-extern struct regcache *dummy_frame_context_saver_get_regs
- (struct dummy_frame_context_saver *saver);
-extern struct dummy_frame_context_saver *dummy_frame_context_saver_setup
- (struct frame_id dummy_id, ptid_t ptid);
-
#endif
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index e5d01ff..87b28a5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1588,22 +1588,15 @@ advance_command (char *arg, int from_tty)
right after an inferior call has finished. */
struct value *
-get_return_value (struct value *function, struct type *value_type,
- struct dummy_frame_context_saver *ctx_saver)
+get_return_value (struct value *function, struct type *value_type)
{
- struct regcache *stop_regs = NULL;
+ struct regcache *stop_regs;
struct gdbarch *gdbarch;
struct value *value;
- struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
+ struct cleanup *cleanup;
- /* If registers were not saved, use the current registers. */
- if (ctx_saver != NULL)
- stop_regs = dummy_frame_context_saver_get_regs (ctx_saver);
- else
- {
- stop_regs = regcache_dup (get_current_regcache ());
- make_cleanup_regcache_xfree (stop_regs);
- }
+ stop_regs = regcache_dup (get_current_regcache ());
+ cleanup = make_cleanup_regcache_xfree (stop_regs);
gdbarch = get_regcache_arch (stop_regs);
@@ -1803,7 +1796,7 @@ finish_command_fsm_should_stop (struct thread_fsm *self)
struct value *func;
func = read_var_value (f->function, get_current_frame ());
- rv->value = get_return_value (func, rv->type, NULL);
+ rv->value = get_return_value (func, rv->type);
rv->value_history_index = record_latest_value (rv->value);
}
}
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 48cba45..e09cb00 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -165,10 +165,8 @@ extern void detach_command (char *, int);
extern void notice_new_inferior (ptid_t, int, int);
-struct dummy_frame_context_saver;
-extern struct value *get_return_value
- (struct value *function, struct type *value_type,
- struct dummy_frame_context_saver *ctx_saver);
+extern struct value *get_return_value (struct value *function,
+ struct type *value_type);
/* Prepare for execution command. TARGET is the target that will run
the command. BACKGROUND determines whether this is a foreground
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index e543bb3..e1629b0 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -107,10 +107,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
value_object_to_value (self_finishbp->function_value);
struct type *value_type =
type_object_to_type (self_finishbp->return_type);
-
- /* bpfinishpy_init cannot finish into DUMMY_FRAME (throws an error
- in such case) so it is OK to always pass CTX_SAVER as NULL. */
- struct value *ret = get_return_value (function, value_type, NULL);
+ struct value *ret = get_return_value (function, value_type);
if (ret)
{
--
1.9.3
next prev parent reply other threads:[~2015-08-12 17:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-12 17:02 [PATCH 0/7] Replace continuations with an extendable "class" Pedro Alves
2015-08-12 17:02 ` [PATCH 3/7] Convert infcalls to thread_fsm mechanism Pedro Alves
2015-08-12 17:02 ` [PATCH 2/7] Replace "struct continuation" mechanism by something more extensible Pedro Alves
2015-08-18 12:50 ` Yao Qi
2015-08-19 14:55 ` Pedro Alves
2015-08-12 17:02 ` [PATCH 1/7] Merge async and sync code paths some more Pedro Alves
2015-08-12 19:48 ` Simon Marchi
2015-08-17 17:54 ` Pedro Alves
2015-08-17 19:28 ` Simon Marchi
2015-08-18 10:48 ` Yao Qi
2015-08-19 14:11 ` Pedro Alves
2015-08-27 13:26 ` Yao Qi
2015-10-16 0:35 ` Joel Brobecker
2015-10-16 12:24 ` Pedro Alves
2015-10-16 16:22 ` Joel Brobecker
2015-10-16 16:37 ` Pedro Alves
2015-10-16 17:05 ` Joel Brobecker
2015-10-22 16:18 ` Pedro Alves
2015-08-12 17:02 ` [PATCH 4/7] Convert the until/advance commands to thread_fsm mechanism Pedro Alves
2015-08-12 17:11 ` [PATCH 6/7] Garbage collect thread continuations Pedro Alves
2015-08-12 17:11 ` Pedro Alves [this message]
2015-08-12 17:11 ` [PATCH 7/7] Delete enum inferior_event_handler::INF_TIMER Pedro Alves
2015-08-18 11:22 ` Yao Qi
2015-08-18 12:52 ` [PATCH 0/7] Replace continuations with an extendable "class" Yao Qi
2015-08-19 14:56 ` Pedro Alves
2015-09-09 17:33 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439398917-22761-6-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox