This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] sh-tdep.c: Begin evaluating calling_convention
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 12 Oct 2004 17:55:42 +0200
- Subject: [RFA] sh-tdep.c: Begin evaluating calling_convention
- Reply-to: gdb-patches at sources dot redhat dot com
Hi,
the below patch uses the calling convention value to implement a function
which in turn can be used in depending function calls as return_value and
push_dummy_call.
This also introduces a new `set sh calling_convention' resp. a
`show sh calling_convention' in the CLI. Valid values are "auto", "gcc"
and "renesas". The default is "auto".
If set to "auto", the new function sh_effective_calling_convention returns
the value which is given by the calling_convention attribute of the function
in question.
If set to "gcc" or "renesas", this setting overrides the calling_convention
given for the function in question. This is very useful if e.g. the debug
information is missing for the compilation unit or if the calling_convention
information is wrong for whatever reason.
Btw., this code uses a deprecated function deprecated_add_show_from_set.
Somehow I didn't find a way to get the same functionality using
non-deprecated functions. I tried using add_setshow_string_cmd,
but for some reason I could enter any string when using
`set sh calling_convention', not just one of the blessed strings
"auto", "gcc" or "renesas". Any hint appreciated.
Corinna
* sh-tdep.c (setshcmdlist): New static cmd_list_element.
(showshcmdlist): Ditto.
(sh_cc_auto): Ditto.
(sh_cc_gcc): Ditto.
(sh_cc_renesas): Ditto.
(sh_cc_enum): New array pointing to calling convention strings.
(sh_active_calling_convention): New variable pointing to
current active calling convention.
(sh_effective_calling_convention): New static function implementing
evaluation of a function's calling_convention.
(show_sh_command): New function.
(set_sh_command): New function.
(_initialize_sh_tdep): Initialize new "set sh calling-convention",
"show sh calling-convention" commands.
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.177
diff -u -p -r1.177 sh-tdep.c
--- sh-tdep.c 6 Oct 2004 08:59:02 -0000 1.177
+++ sh-tdep.c 12 Oct 2004 15:52:27 -0000
@@ -73,6 +74,37 @@ struct sh_frame_cache
CORE_ADDR saved_sp;
};
+/* List of "set sh ..." and "show sh ..." commands. */
+static struct cmd_list_element *setshcmdlist = NULL;
+static struct cmd_list_element *showshcmdlist = NULL;
+
+static const char sh_cc_auto[] = "auto";
+static const char sh_cc_gcc[] = "gcc";
+static const char sh_cc_renesas[] = "renesas";
+static const char *sh_cc_enum[] = {
+ sh_cc_auto,
+ sh_cc_gcc,
+ sh_cc_renesas,
+ NULL
+};
+
+static const char *sh_active_calling_convention = sh_cc_auto;
+
+static const char *
+sh_effective_calling_convention (struct type *func_type)
+{
+ /* Explicitly setting the calling convention overrides the given
+ calling_convention in the function type. */
+ if (sh_active_calling_convention != sh_cc_auto)
+ return sh_active_calling_convention;
+ /* That's the normal case. We evaluate the function type's calling
+ convention field. */
+ if (func_type)
+ return TYPE_CALLING_CONVENTION (func_type) ? sh_cc_renesas : sh_cc_gcc;
+ /* If we have no information, fall back to GCC calling convention */
+ return sh_cc_gcc;
+}
+
static const char *
sh_sh_register_name (int reg_nr)
{
@@ -2721,6 +2779,20 @@ sh_gdbarch_init (struct gdbarch_info inf
return gdbarch;
}
+static void
+show_sh_command (char *args, int from_tty)
+{
+ help_list (showshcmdlist, "show sh ", all_commands, gdb_stdout);
+}
+
+static void
+set_sh_command (char *args, int from_tty)
+{
+ printf_unfiltered
+ ("\"set sh\" must be followed by an appropriate subcommand.\n");
+ help_list (setshcmdlist, "set sh ", all_commands, gdb_stdout);
+}
+
extern initialize_file_ftype _initialize_sh_tdep; /* -Wmissing-prototypes */
void
@@ -2731,4 +2803,15 @@ _initialize_sh_tdep (void)
gdbarch_register (bfd_arch_sh, sh_gdbarch_init, NULL);
add_com ("regs", class_vars, sh_show_regs_command, "Print all registers");
+
+ add_prefix_cmd ("sh", no_class, set_sh_command, "SH specific commands.",
+ &setshcmdlist, "set sh ", 0, &setlist);
+ add_prefix_cmd ("sh", no_class, show_sh_command, "SH specific commands.",
+ &showshcmdlist, "show sh ", 0, &showlist);
+
+ deprecated_add_show_from_set (add_set_enum_cmd
+ ("calling-convention", class_vars, sh_cc_enum,
+ &sh_active_calling_convention,
+ "Set calling convention used when calling target "
+ "functions from GDB.", &setshcmdlist), &showshcmdlist);
}
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.