From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14518 invoked by alias); 12 Oct 2004 15:54:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 14511 invoked from network); 12 Oct 2004 15:54:45 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 Oct 2004 15:54:45 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i9CFsj98003375 for ; Tue, 12 Oct 2004 11:54:45 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9CFsir22215 for ; Tue, 12 Oct 2004 11:54:44 -0400 Received: from cygbert.vinschen.de (vpn50-21.rdu.redhat.com [172.16.50.21]) by potter.sfbay.redhat.com (8.12.8/8.12.8) with ESMTP id i9CFsf0O002057 for ; Tue, 12 Oct 2004 11:54:42 -0400 Received: by cygbert.vinschen.de (Postfix, from userid 500) id E34F958090; Tue, 12 Oct 2004 17:55:42 +0200 (CEST) Date: Tue, 12 Oct 2004 15:54:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] sh-tdep.c: Begin evaluating calling_convention Message-ID: <20041012155542.GC6702@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i X-SW-Source: 2004-10/txt/msg00214.txt.bz2 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.