From: "Tankut Baris Aktemur (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: gdb-patches@sourceware.org
Subject: [review] infcall: move assertions in 'call_function_by_hand_dummy' to an earli...
Date: Fri, 18 Oct 2019 13:53:00 -0000 [thread overview]
Message-ID: <gerrit.1571406803000.I411ac083ac6a9ee6eb93c4b82393a81a4fc927be@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1571406803000.I411ac083ac6a9ee6eb93c4b82393a81a4fc927be@gnutoolchain-gerrit.osci.io>
Tankut Baris Aktemur has uploaded a new change for review.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/139
......................................................................
infcall: move assertions in 'call_function_by_hand_dummy' to an earlier spot
This is a refactoring that performs type assertions on the callee
function at the beginning of 'call_function_by_hand_dummy' rather than
at a later point.
gdb/ChangeLog:
2019-MM-DD Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infcall.c (call_function_by_hand_dummy): Refactor.
Change-Id: I411ac083ac6a9ee6eb93c4b82393a81a4fc927be
---
M gdb/infcall.c
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/gdb/infcall.c b/gdb/infcall.c
index a342310..629a83c 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -782,6 +782,27 @@
if (!gdbarch_push_dummy_call_p (gdbarch))
error (_("This target does not support function calls."));
+ /* Find the function type and do a sanity check. */
+ type *ftype;
+ type *values_type;
+ CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype);
+
+ if (values_type == NULL)
+ values_type = default_return_type;
+ if (values_type == NULL)
+ {
+ const char *name = get_function_name (funaddr,
+ name_buf, sizeof (name_buf));
+ error (_("'%s' has unknown return type; "
+ "cast the call to its declared return type"),
+ name);
+ }
+
+ values_type = check_typedef (values_type);
+
+ if (args.size () < TYPE_NFIELDS (ftype))
+ error (_("Too few arguments in function call."));
+
/* A holder for the inferior status.
This is only needed while we're preparing the inferior function call. */
infcall_control_state_up inf_status (save_infcall_control_state ());
@@ -887,23 +908,6 @@
}
}
- type *ftype;
- type *values_type;
- CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype);
-
- if (values_type == NULL)
- values_type = default_return_type;
- if (values_type == NULL)
- {
- const char *name = get_function_name (funaddr,
- name_buf, sizeof (name_buf));
- error (_("'%s' has unknown return type; "
- "cast the call to its declared return type"),
- name);
- }
-
- values_type = check_typedef (values_type);
-
/* Are we returning a value using a structure return? */
if (gdbarch_return_in_first_hidden_param_p (gdbarch, values_type))
@@ -981,9 +985,6 @@
internal_error (__FILE__, __LINE__, _("bad switch"));
}
- if (args.size () < TYPE_NFIELDS (ftype))
- error (_("Too few arguments in function call."));
-
for (int i = args.size () - 1; i >= 0; i--)
{
int prototyped;
next parent reply other threads:[~2019-10-18 13:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 13:53 Tankut Baris Aktemur (Code Review) [this message]
2019-10-18 15:10 ` Tom de Vries (Code Review)
2019-10-21 7:36 ` Tankut Baris Aktemur (Code Review)
2019-10-21 18:55 ` Luis Machado (Code Review)
2019-10-21 19:00 ` Simon Marchi (Code Review)
2019-10-22 7:13 ` [review v2] " Tankut Baris Aktemur (Code Review)
2019-10-22 7:19 ` Tankut Baris Aktemur (Code Review)
2019-10-22 8:57 ` Tom de Vries (Code Review)
2019-10-22 16:27 ` Simon Marchi (Code Review)
2019-10-23 18:50 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-10-23 18:50 ` Sourceware to Gerrit sync (Code Review)
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=gerrit.1571406803000.I411ac083ac6a9ee6eb93c4b82393a81a4fc927be@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=gdb-patches@sourceware.org \
--cc=tankut.baris.aktemur@intel.com \
/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