From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22261 invoked by alias); 13 Mar 2002 18:56:33 -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 22096 invoked from network); 13 Mar 2002 18:56:24 -0000 Received: from unknown (HELO mail-out1.apple.com) (17.254.0.52) by sources.redhat.com with SMTP; 13 Mar 2002 18:56:24 -0000 Received: from mailgate1.apple.com (A17-128-100-225.apple.com [17.128.100.225]) by mail-out1.apple.com (8.11.3/8.11.3) with ESMTP id g2DIuOQ25109 for ; Wed, 13 Mar 2002 10:56:24 -0800 (PST) Received: from scv1.apple.com (scv1.apple.com) by mailgate1.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Wed, 13 Mar 2002 10:56:00 -0800 Received: from inghji (inghji.apple.com [17.202.40.220]) by scv1.apple.com (8.11.3/8.11.3) with ESMTP id g2DIuNv12741 for ; Wed, 13 Mar 2002 10:56:23 -0800 (PST) Date: Wed, 13 Mar 2002 10:56:00 -0000 Mime-Version: 1.0 (Apple Message framework v481) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: add set cp-abi command From: Jim Ingham To: gdb-patches@sources.redhat.com Content-Transfer-Encoding: 7bit Message-Id: <0337C4EC-36B4-11D6-95FF-000393540DDC@apple.com> X-Mailer: Apple Mail (2.481) X-SW-Source: 2002-03/txt/msg00201.txt.bz2 Hi, all... gdb assumes that it will never see a mix of gcc2 & gcc3 compiled C++ code in a single executable. So it determines which abi to use by setting it to gnu-v2, and then if it EVER sees a v3 style mangled name, it switches it to v3. This breaks down in the case where you have some shared libraries compiled with gcc3, but the user code is compiled with gcc2. This is a perfectly okay thing to do if the libraries don't export any C++ symbols, but gdb will get the abi wrong, and you won't be able to print any C++ objects in the user code. Ouch! I am not currently proposing any fancy mechanism to try to switch on the fly between the two. The problem is temporary so I don't really think it is worth the effort to cook up such a scheme. Rather, I just added a "set cp-abi" command so that my users can fix the problem by hand when they notice it arising. Here is the patch: 2002-03-12 James Ingham * cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd, show_cp_abis_cmd): New functions, allow you to set & show cplus abi's in case gdb gets it wrong. (_initialize_cp_abi): Define the cp-abi switching commands. Index: cp-abi.c =================================================================== RCS file: /cvs/src/src/gdb/cp-abi.c,v retrieving revision 1.3 diff -c -w -r1.3 cp-abi.c *** cp-abi.c 2002/01/04 18:20:19 1.3 --- cp-abi.c 2002/03/13 18:46:57 *************** *** 21,26 **** --- 21,29 ---- #include "defs.h" #include "value.h" #include "cp-abi.h" + #include "command.h" + #include "ui-out.h" + #include "gdbcmd.h" struct cp_abi_ops current_cp_abi; *************** *** 103,109 **** --- 106,164 ---- int i; for (i = 0; i < num_cp_abis; i++) if (strcmp (cp_abis[i].shortname, short_name) == 0) + { current_cp_abi = cp_abis[i]; return 1; + } + + return 0; + } + + void + set_cp_abi_cmd (char *args, int from_tty) + { + + if (!switch_to_cp_abi (args)) + error ("Could not find ABI: \"%s\" in ABI list\n", args); + } + + void + show_cp_abi_cmd (char *args, int from_tty) + { + ui_out_text (uiout, "The current cplus abi is: "); + + ui_out_field_string (uiout, "cp-abi", current_cp_abi.shortname); + ui_out_text (uiout, ".\n"); + } + + void + show_cp_abis_cmd (char *args, int from_tty) + { + int i; + ui_out_text (uiout, "The valid cplus abi's are:\n"); + + ui_out_tuple_begin (uiout, "cp-abi-list"); + for (i = 0; i < num_cp_abis; i++) + { + ui_out_field_string (uiout, "cp-abi", cp_abis[i].shortname); + ui_out_text (uiout, "\n"); + } + ui_out_tuple_end (uiout); + + } + + void + _initialize_cp_abi (void) + { + struct cmd_list_element *cmd; + + cmd = add_cmd ("cp-abi", class_obscure , set_cp_abi_cmd, + "Set the ABI used for inspecting C++ objects", &setlist); + + cmd = add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd, + "Show the ABI used for inspecting C++ objects", &showlist); + cmd = add_cmd ("cp-abis", class_obscure, show_cp_abis_cmd, + "List the available ABIs for inspecting C++ objects", &showlist); + } Jim -- Jim Ingham jingham@apple.com Developer Tools - gdb Apple Computer