From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] Change thread_fsm::return_value to thread_fsm::print_return_values
Date: Sat, 10 Dec 2022 17:23:24 +0100 [thread overview]
Message-ID: <20221210162326.854-1-ssbssa@yahoo.de> (raw)
In-Reply-To: <20221210162326.854-1-ssbssa.ref@yahoo.de>
A later patch implements print_return_values also for step_command_fsm,
to print the return values of all stepped-over functions.
This keeps all of the return value printing code in infrun.c, so
print_return_value could be made static.
---
gdb/infcmd.c | 12 ++++++------
gdb/infrun.c | 11 ++---------
gdb/infrun.h | 7 -------
gdb/thread-fsm.h | 6 ++----
4 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index a27d3577b3a..a5fcf2f8ea5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1575,7 +1575,7 @@ print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv)
RV points at an object representing the captured return value/type
and its position in the value history. */
-void
+static void
print_return_value (struct ui_out *uiout, struct return_value_info *rv)
{
if (rv->type == nullptr
@@ -1623,7 +1623,7 @@ struct finish_command_fsm : public thread_fsm
bool should_stop (struct thread_info *thread) override;
void clean_up (struct thread_info *thread) override;
- struct return_value_info *return_value () override;
+ void print_return_values (struct ui_out *uiout) override;
enum async_reply_reason do_async_reply_reason () override;
};
@@ -1684,13 +1684,13 @@ finish_command_fsm::clean_up (struct thread_info *thread)
delete_longjmp_breakpoint (thread->global_num);
}
-/* Implementation of the 'return_value' FSM method for the finish
+/* Implementation of the 'print_return_values' FSM method for the finish
commands. */
-struct return_value_info *
-finish_command_fsm::return_value ()
+void
+finish_command_fsm::print_return_values (struct ui_out *uiout)
{
- return &return_value_info;
+ print_return_value (uiout, &return_value_info);
}
/* Implementation of the 'async_reply_reason' FSM method for the
diff --git a/gdb/infrun.c b/gdb/infrun.c
index c67458b30b6..e8ef3677245 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8490,15 +8490,8 @@ print_stop_event (struct ui_out *uiout, bool displays)
}
tp = inferior_thread ();
- if (tp->thread_fsm () != nullptr
- && tp->thread_fsm ()->finished_p ())
- {
- struct return_value_info *rv;
-
- rv = tp->thread_fsm ()->return_value ();
- if (rv != nullptr)
- print_return_value (uiout, rv);
- }
+ if (tp->thread_fsm () != nullptr)
+ tp->thread_fsm ()->print_return_values (uiout);
}
/* See infrun.h. */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index c711b9b21cc..79323bcc65f 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -225,13 +225,6 @@ extern void print_exited_reason (struct ui_out *uiout, int exitstatus);
inferior has stopped. */
extern void print_no_history_reason (struct ui_out *uiout);
-/* Print the result of a function at the end of a 'finish' command.
- RV points at an object representing the captured return value/type
- and its position in the value history. */
-
-extern void print_return_value (struct ui_out *uiout,
- struct return_value_info *rv);
-
/* Print current location without a level number, if we have changed
functions or hit a breakpoint. Print source line if we have one.
If the execution command captured a return value, print it. If
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index 96f37ac9414..575b9a5e48f 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -58,11 +58,9 @@ struct thread_fsm
function's return value here. */
virtual bool should_stop (struct thread_info *thread) = 0;
- /* If this FSM saved a function's return value, you can use this
- method to retrieve it. Otherwise, this returns NULL. */
- virtual struct return_value_info *return_value ()
+ /* Print return values saved by this FSM. */
+ virtual void print_return_values (struct ui_out *uiout)
{
- return nullptr;
}
enum async_reply_reason async_reply_reason ()
--
2.35.1
next parent reply other threads:[~2022-12-10 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221210162326.854-1-ssbssa.ref@yahoo.de>
2022-12-10 16:23 ` Hannes Domani [this message]
2022-12-10 16:23 ` [PATCH 2/3] Move return_value_info and refactor code setting its members Hannes Domani
2022-12-10 16:23 ` [PATCH 3/3] [RFC] Implement printing of return values of stepped-over functions Hannes Domani
2022-12-10 16:33 ` Eli Zaretskii
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=20221210162326.854-1-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).