Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* add set cp-abi command
@ 2002-03-13 10:56 Jim Ingham
  2002-03-13 12:11 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Jim Ingham @ 2002-03-13 10:56 UTC (permalink / raw)
  To: gdb-patches

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 <jingham@apple.com>

         * 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


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-13 10:56 add set cp-abi command Jim Ingham
@ 2002-03-13 12:11 ` Eli Zaretskii
  2002-03-13 12:11 ` Daniel Jacobowitz
  2002-03-14 15:29 ` Andrew Cagney
  2 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2002-03-13 12:11 UTC (permalink / raw)
  To: jingham; +Cc: gdb-patches

> Date: Wed, 13 Mar 2002 10:56:22 -0800
> From: Jim Ingham <jingham@apple.com>
> 
> 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.

Thanks, but please add something to gdb.texinfo to document this
command.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-13 10:56 add set cp-abi command Jim Ingham
  2002-03-13 12:11 ` Eli Zaretskii
@ 2002-03-13 12:11 ` Daniel Jacobowitz
  2002-03-14 13:14   ` Jim Ingham
  2002-03-14 15:29 ` Andrew Cagney
  2 siblings, 1 reply; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-13 12:11 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Wed, Mar 13, 2002 at 10:56:22AM -0800, Jim Ingham wrote:
> 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.

We could reasonably have an ABI per-objfile.  In fact, we probably
should... it's not clear how that would interact with this patch.  But
I'm not going to ask you to do that.

I think it might be wiser to have cp-abi default to "auto" and
condition the autoselection magic based on that.  Otherwise, if you set
it to v2, it is likely to autorevert to v3 unexpectedly.  Could you add
that change?

> 2002-03-12  James Ingham <jingham@apple.com>
> 
>         * 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.

Also, a couple of small changes (below).

> ***************
> *** 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;
> + }

Indentation, of course.

> +
> + 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: ");

"currently selected C++ ABI", please.

> +
> +   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");

"C++ ABIs" (or ABI's? ABIs, I think, if there isn't a precedent)

> +
> +   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);

I believe 'show cp-abi' should show the available ABIs.  That's more in
keeping with existing code.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-13 12:11 ` Daniel Jacobowitz
@ 2002-03-14 13:14   ` Jim Ingham
  2002-03-14 13:26     ` Daniel Jacobowitz
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-03-14 13:14 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel,

On Wednesday, March 13, 2002, at 12:11  PM, Daniel Jacobowitz wrote:

> On Wed, Mar 13, 2002 at 10:56:22AM -0800, Jim Ingham wrote:
>> 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.
>
> We could reasonably have an ABI per-objfile.  In fact, we probably
> should... it's not clear how that would interact with this patch.  But
> I'm not going to ask you to do that.

Thanks...  I am not sure it is really worth the effort.  It is not 
really something we want to encourage folks to do, after all, and in 
time the issue will fade away...

>
> I think it might be wiser to have cp-abi default to "auto" and
> condition the autoselection magic based on that.  Otherwise, if you set
> it to v2, it is likely to autorevert to v3 unexpectedly.  Could you add
> that change?

Okay.  I almost got this working last night, and thought I would have 
time to finish it today, but got hung up on some other emergency...


>
>> 2002-03-12  James Ingham <jingham@apple.com>
>>
>>         * 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.
>
> Also, a couple of small changes (below).
>
>> ***************
>> *** 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;
>> + }
>
> Indentation, of course.

This is actually mailer mangling, it was right in the sources. $%#$#$$# 
GUI mailers...

>
>> +
>> + 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: ");
>
> "currently selected C++ ABI", please.

As you wish...

>
>> +
>> +   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");
>
> "C++ ABIs" (or ABI's? ABIs, I think, if there isn't a precedent)

We actually checked Strunk & White, and as of the mid 30's, this should 
be ABIs...

>
>> +
>> +   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);
>
> I believe 'show cp-abi' should show the available ABIs.  That's more in
> keeping with existing code.

How would you find out the current ABI, then?  Probably better is to 
chuck the show abis, and let "set cp-abi" (with no arguments) perform 
this function.  This is the way "set language" works, so it has 
precedent.  I was sure that there was another command that used the 
singular lists current, plural lists all, but I can't find it so maybe I 
was just out of my mind...

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-14 13:14   ` Jim Ingham
@ 2002-03-14 13:26     ` Daniel Jacobowitz
  2002-03-15 15:53       ` Jim Ingham
  2002-03-15 17:11       ` Jim Ingham
  0 siblings, 2 replies; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-14 13:26 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Thu, Mar 14, 2002 at 01:14:09PM -0800, Jim Ingham wrote:
> Thanks...  I am not sure it is really worth the effort.  It is not 
> really something we want to encourage folks to do, after all, and in 
> time the issue will fade away...

Very true.  And by definition, there should really only be one ABI...
if it comes up as a bug again somewhere else, we can look into this.

> >>***************
> >>*** 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;
> >>+ }
> >
> >Indentation, of course.
> 
> This is actually mailer mangling, it was right in the sources. $%#$#$$# 
> GUI mailers...

Well, unless your mailer ate a "+" at the beginning of "return 1;", it
wasn't right in the mail.  That line is moving over.  I'm sure you'll
have it right when you commit it :)

> >"currently selected C++ ABI", please.
> 
> As you wish...

Thanks.  We may not have consistent grammar or spelling in our messages
right now, but I'm still all over trying.

> >>+   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");
> >
> >"C++ ABIs" (or ABI's? ABIs, I think, if there isn't a precedent)
> 
> We actually checked Strunk & White, and as of the mid 30's, this should 
> be ABIs...

"ABIs" looks like what I remember, too, so let's use that.

> >I believe 'show cp-abi' should show the available ABIs.  That's more in
> >keeping with existing code.
> 
> How would you find out the current ABI, then?  Probably better is to 
> chuck the show abis, and let "set cp-abi" (with no arguments) perform 
> this function.  This is the way "set language" works, so it has 
> precedent.  I was sure that there was another command that used the 
> singular lists current, plural lists all, but I can't find it so maybe I 
> was just out of my mind...

Shall we agree to mimic "set language", then?

[For anyone following along:

(gdb) set language
The currently understood settings are:

local or auto    Automatic setting based on source file
c                Use the C language
c++              Use the C++ language
asm              Use the Asm language
chill            Use the Chill language
fortran          Use the Fortran language
java             Use the Java language
modula-2         Use the Modula-2 language
pascal           Use the Pascal language
scheme           Use the Scheme language
(gdb) show language
The current source language is "auto; currently c".

]

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-13 10:56 add set cp-abi command Jim Ingham
  2002-03-13 12:11 ` Eli Zaretskii
  2002-03-13 12:11 ` Daniel Jacobowitz
@ 2002-03-14 15:29 ` Andrew Cagney
  2002-03-15 10:33   ` Jim Ingham
  2 siblings, 1 reply; 25+ messages in thread
From: Andrew Cagney @ 2002-03-14 15:29 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

Jim, an aside.  The code should use:

	extern struct cmd_list_element *add_set_enum_cmd ();

so that:

	(gdb) set cp-abi <tab>

works.

Andrew


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-14 15:29 ` Andrew Cagney
@ 2002-03-15 10:33   ` Jim Ingham
  2002-03-15 17:29     ` Andrew Cagney
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-03-15 10:33 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew,

No, I can't do it this way, because the cp-abi.c file where the command 
is defined doesn't know what all the available abi's are.  They are 
added dynamically by the other *-abi.c files.  The same is true with the 
set language command in language.c, for example...  I would have to add 
a special completer function to get this to work, and I must admit that 
is a little beyond the merits of this command, which is, after all, only 
needed in emergencies, rather than being a workaday type command.

Jim

On Thursday, March 14, 2002, at 02:38  PM, Andrew Cagney wrote:

> Jim, an aside.  The code should use:
>
> 	extern struct cmd_list_element *add_set_enum_cmd ();
>
> so that:
>
> 	(gdb) set cp-abi <tab>
>
> works.
>
> Andrew
>
>
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-14 13:26     ` Daniel Jacobowitz
@ 2002-03-15 15:53       ` Jim Ingham
  2002-03-15 19:41         ` Daniel Jacobowitz
  2002-03-15 17:11       ` Jim Ingham
  1 sibling, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-03-15 15:53 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel,

Okay, how about this.

I changed the set/show as per set language.

I added an "auto" abi.  This ended up being a little tricky because I 
don't know the order in which the initializers get run, but this works.

In the process of doing this I got really annoyed that EVERYTHING was 
done by copying structures around.  If we think that it is really 
important to have the current_cp_abi be a structure rather than a 
pointer to a structure so there was one less level of indirection, 
that's fine.  But there is no reason to manage the internal list this 
way as well.  So I changed cp_abis to be an array of pointers to 
cp_abi_ops structures, and had to change the auto-grow mechanism to 
account for it.

I also took out the extern def'ns of num_cp_abis, cp_abis and 
current_cp_abi out of cp-abi.h.  They weren't currently used outside the 
module, and if we end up needing to use them, we should provide 
interfaces, rather than just poking around at the data.

I haven't written a doc note for this, I have run out of time for this 
today, but thought I would give you a look before the day is out...

What do you think of this:

Index: cp-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 cp-abi.c
*** cp-abi.c    2002/01/04 18:20:19     1.3
--- cp-abi.c    2002/03/15 23:46:26
***************
*** 21,33 ****
   #include "defs.h"
   #include "value.h"
   #include "cp-abi.h"

! struct cp_abi_ops current_cp_abi;

! struct cp_abi_ops *cp_abis;

! int num_cp_abis = 0;

   enum ctor_kinds
   is_constructor_name (const char *name)
   {
--- 21,41 ----
   #include "defs.h"
   #include "value.h"
   #include "cp-abi.h"
+ #include "command.h"
+ #include "ui-out.h"
+ #include "gdbcmd.h"

! static struct cp_abi_ops current_cp_abi;
! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};

! #define INITIAL_CP_ABI_MAX 8

! static struct cp_abi_ops *orig_cp_abis[INITIAL_CP_ABI_MAX];
! static struct cp_abi_ops **cp_abis = orig_cp_abis;
! static int max_cp_abis = INITIAL_CP_ABI_MAX;

+ static int num_cp_abis = 0;
+
   enum ctor_kinds
   is_constructor_name (const char *name)
   {
*************** value_rtti_type (struct value *v, int *f
*** 87,109 ****
   }

   int
! register_cp_abi (struct cp_abi_ops abi)
   {
!   cp_abis =
!     xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
     cp_abis[num_cp_abis++] = abi;

     return 1;

   }

   int
   switch_to_cp_abi (const char *short_name)
   {
     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;
   }

--- 95,231 ----
   }

   int
! register_cp_abi (struct cp_abi_ops *abi)
! {
!   if (num_cp_abis == max_cp_abis)
       {
!       struct cp_abi_ops **new_abi_list;
!       int i;
!
!       max_cp_abis *= 2;
!       new_abi_list = (struct cp_abi_ops **) xmalloc (max_cp_abis * 
sizeof (struct cp_abi_ops *));
!       for (i = 0; i < num_cp_abis; i++)
!         new_abi_list[i] = cp_abis[i];
!
!       if (cp_abis != orig_cp_abis)
!       xfree (cp_abis);
!
!       cp_abis = new_abi_list;
!     }
!
     cp_abis[num_cp_abis++] = abi;

     return 1;

   }

+ void
+ set_cp_abi_as_auto_default (struct cp_abi_ops *abi)
+ {
+
+   if (auto_cp_abi.longname != NULL)
+     xfree (auto_cp_abi.longname);
+   auto_cp_abi.longname = (char *) xmalloc (11 + strlen 
(abi->shortname));
+   sprintf (auto_cp_abi.longname, "currently %s",
+          abi->shortname);
+
+   if (auto_cp_abi.doc != NULL)
+     xfree (auto_cp_abi.doc);
+   auto_cp_abi.doc = (char *) xmalloc (11 + strlen (abi->shortname));
+   sprintf (auto_cp_abi.doc, "currently %s",
+          abi->shortname);
+
+   auto_cp_abi.is_destructor_name = abi->is_destructor_name;
+   auto_cp_abi.is_constructor_name = abi->is_constructor_name;
+   auto_cp_abi.is_vtable_name = abi->is_vtable_name;
+   auto_cp_abi.is_operator_name = abi->is_operator_name;
+   auto_cp_abi.virtual_fn_field = abi->virtual_fn_field;
+   auto_cp_abi.rtti_type = abi->rtti_type;
+   auto_cp_abi.baseclass_offset = abi->baseclass_offset;
+
+   /* Since we copy the current ABI into current_cp_abi instead of using
+      a pointer, if auto is currently the default, we need to reset 
it. */
+
+   if (cp_abi_is_auto_p ())
+     switch_to_cp_abi ("auto");
+ }
+
+ int
+ cp_abi_is_auto_p ()
+ {
+   if (strcmp (current_cp_abi.shortname, "auto") == 0)
+     return 1;
+   else
+     return 0;
+ }
+
   int
   switch_to_cp_abi (const char *short_name)
   {
     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
+ show_cp_abis (int from_tty)
+ {
+   int i;
+   ui_out_text (uiout, "The available C++ ABIs 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_fmt (uiout, " - %s\n", cp_abis[i]->doc);
+     }
+   ui_out_tuple_end (uiout);
+
+ }
+
+ void
+ set_cp_abi_cmd (char *args, int from_tty)
+ {
+
+   if (args == NULL)
+     {
+       show_cp_abis (from_tty);
+       return;
+     }
+
+   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 currently selected C++ abi is: ");
+
+   ui_out_field_string (uiout, "cp-abi", current_cp_abi.shortname);
+   ui_out_text (uiout, ".\n");
+ }
+
+ void
+ _initialize_cp_abi (void)
+ {
+   struct cmd_list_element *cmd;
+
+   register_cp_abi (&auto_cp_abi);
+   switch_to_cp_abi ("auto");
+
+   cmd = add_cmd ("cp-abi", class_obscure , set_cp_abi_cmd,
+                "Set the ABI used for inspecting C++ objects.\n\
+ \"set cp-abi\" with no arguments will list the available ABIs.", 
&setlist);
+
+   cmd = add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd,
+                "Show the ABI used for inspecting C++ objects.", 
&showlist);
+
+ }
Index: cp-abi.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.h,v
retrieving revision 1.4
diff -c -w -p -r1.4 cp-abi.h
*** cp-abi.h    2002/01/04 18:20:19     1.4
--- cp-abi.h    2002/03/15 23:46:28
*************** extern int baseclass_offset (struct type
*** 146,153 ****
   struct cp_abi_ops
   {
     const char *shortname;
!   const char *longname;
!   const char *doc;

     /* ABI-specific implementations for the functions declared above.  */
     enum ctor_kinds (*is_constructor_name) (const char *name);
--- 146,153 ----
   struct cp_abi_ops
   {
     const char *shortname;
!   char *longname; /* These two can't be const, because I need to */
!   char *doc;      /* change the name for the auto abi. */

     /* ABI-specific implementations for the functions declared above.  */
     enum ctor_kinds (*is_constructor_name) (const char *name);
*************** struct cp_abi_ops
*** 163,173 ****
   };


! extern struct cp_abi_ops *cp_abis;
! extern int num_cp_abis;
! extern struct cp_abi_ops current_cp_abi;
! extern int register_cp_abi (struct cp_abi_ops abi);
   extern int switch_to_cp_abi (const char *short_name);

   #endif

--- 163,172 ----
   };


! extern int register_cp_abi (struct cp_abi_ops *abi);
   extern int switch_to_cp_abi (const char *short_name);
+ extern void set_cp_abi_as_auto_default (struct cp_abi_ops *abi);
+ extern int cp_abi_is_auto_p ();

   #endif

Index: gnu-v2-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v2-abi.c,v
retrieving revision 1.6
diff -c -w -p -r1.6 gnu-v2-abi.c
*** gnu-v2-abi.c        2002/01/04 18:20:19     1.6
--- gnu-v2-abi.c        2002/03/15 23:46:28
*************** void
*** 424,429 ****
   _initialize_gnu_v2_abi (void)
   {
     init_gnuv2_ops ();
!   register_cp_abi (gnu_v2_abi_ops);
!   switch_to_cp_abi ("gnu-v2");
   }
--- 424,429 ----
   _initialize_gnu_v2_abi (void)
   {
     init_gnuv2_ops ();
!   register_cp_abi (&gnu_v2_abi_ops);
!   set_cp_abi_as_auto_default (&gnu_v2_abi_ops);
   }
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.8
diff -c -w -p -r1.8 gnu-v3-abi.c
*** gnu-v3-abi.c        2002/02/02 00:04:46     1.8
--- gnu-v3-abi.c        2002/03/15 23:46:28
*************** _initialize_gnu_v3_abi (void)
*** 430,434 ****
   {
     init_gnuv3_ops ();

!   register_cp_abi (gnu_v3_abi_ops);
   }
--- 430,434 ----
   {
     init_gnuv3_ops ();

!   register_cp_abi (&gnu_v3_abi_ops);
   }
Index: hpacc-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/hpacc-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 hpacc-abi.c
*** hpacc-abi.c 2002/01/04 18:20:19     1.3
--- hpacc-abi.c 2002/03/15 23:46:28
*************** _initialize_hpacc_abi (void)
*** 324,328 ****
     regcomp (&operator_pattern,
            "^This will never match anything, please fill it in$", 
REG_NOSUB);

!   register_cp_abi (hpacc_abi_ops);
   }
--- 324,328 ----
     regcomp (&operator_pattern,
            "^This will never match anything, please fill it in$", 
REG_NOSUB);

!   register_cp_abi (&hpacc_abi_ops);
   }
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.19
diff -c -w -p -r1.19 minsyms.c
*** minsyms.c   2001/12/10 22:04:10     1.19
--- minsyms.c   2002/03/15 23:46:28
*************** install_minimal_symbols (struct objfile
*** 970,975 ****
--- 970,976 ----
             const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
             if (name[0] == '_' && name[1] == 'Z')
               {
+               if (cp_abi_is_auto_p ())
                   switch_to_cp_abi ("gnu-v3");
                 break;
               }

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-14 13:26     ` Daniel Jacobowitz
  2002-03-15 15:53       ` Jim Ingham
@ 2002-03-15 17:11       ` Jim Ingham
  1 sibling, 0 replies; 25+ messages in thread
From: Jim Ingham @ 2002-03-15 17:11 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Oops, I muffed one line in the patch I sent.  The line:

static struct cp_abi_ops current_cp_abi;

should be:

static struct cp_abi_ops current_cp_abi = {"auto", NULL};

We do intend for auto to be the initial "current" abi, but we can't be 
sure when this will be done (and currently the initializers for 
gnu-v2-abi.c & gnu-v3-abi.c run BEFORE the cp-abi.c initializer).  I 
could fix this, but it is better to make the order not matter.

Jim


On Thursday, March 14, 2002, at 01:26  PM, Daniel Jacobowitz wrote:

> On Thu, Mar 14, 2002 at 01:14:09PM -0800, Jim Ingham wrote:
>> Thanks...  I am not sure it is really worth the effort.  It is not
>> really something we want to encourage folks to do, after all, and in
>> time the issue will fade away...
>
> Very true.  And by definition, there should really only be one ABI...
> if it comes up as a bug again somewhere else, we can look into this.
>
>>>> ***************
>>>> *** 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;
>>>> + }
>>>
>>> Indentation, of course.
>>
>> This is actually mailer mangling, it was right in the sources. $%#$#$$#
>> GUI mailers...
>
> Well, unless your mailer ate a "+" at the beginning of "return 1;", it
> wasn't right in the mail.  That line is moving over.  I'm sure you'll
> have it right when you commit it :)
>
>>> "currently selected C++ ABI", please.
>>
>> As you wish...
>
> Thanks.  We may not have consistent grammar or spelling in our messages
> right now, but I'm still all over trying.
>
>>>> +   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");
>>>
>>> "C++ ABIs" (or ABI's? ABIs, I think, if there isn't a precedent)
>>
>> We actually checked Strunk & White, and as of the mid 30's, this should
>> be ABIs...
>
> "ABIs" looks like what I remember, too, so let's use that.
>
>>> I believe 'show cp-abi' should show the available ABIs.  That's more 
>>> in
>>> keeping with existing code.
>>
>> How would you find out the current ABI, then?  Probably better is to
>> chuck the show abis, and let "set cp-abi" (with no arguments) perform
>> this function.  This is the way "set language" works, so it has
>> precedent.  I was sure that there was another command that used the
>> singular lists current, plural lists all, but I can't find it so 
>> maybe I
>> was just out of my mind...
>
> Shall we agree to mimic "set language", then?
>
> [For anyone following along:
>
> (gdb) set language
> The currently understood settings are:
>
> local or auto    Automatic setting based on source file
> c                Use the C language
> c++              Use the C++ language
> asm              Use the Asm language
> chill            Use the Chill language
> fortran          Use the Fortran language
> java             Use the Java language
> modula-2         Use the Modula-2 language
> pascal           Use the Pascal language
> scheme           Use the Scheme language
> (gdb) show language
> The current source language is "auto; currently c".
>
> ]
>
> --
> Daniel Jacobowitz                           Carnegie Mellon University
> MontaVista Software                         Debian GNU/Linux Developer
>
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-15 10:33   ` Jim Ingham
@ 2002-03-15 17:29     ` Andrew Cagney
  0 siblings, 0 replies; 25+ messages in thread
From: Andrew Cagney @ 2002-03-15 17:29 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

> Andrew,
> 
> No, I can't do it this way, because the cp-abi.c file where the command is defined doesn't know what all the available abi's are.  They are added dynamically by the other *-abi.c files.  The same is true with the set language command in language.c, for example...  I would have to add a special completer function to get this to work, and I must admit that is a little beyond the merits of this command, which is, after all, only needed in emergencies, rather than being a workaday type command.

Ah, yes, sigh.  It should be easy to to do this.  If it isn't there is 
another problem (but outside the scope of your change).  Suggest 
creating a change-request for this.

Andrew



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-15 15:53       ` Jim Ingham
@ 2002-03-15 19:41         ` Daniel Jacobowitz
  2002-03-18 12:01           ` Jim Ingham
  0 siblings, 1 reply; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-15 19:41 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Fri, Mar 15, 2002 at 03:52:47PM -0800, Jim Ingham wrote:
> Daniel,
> 
> Okay, how about this.
> 
> I changed the set/show as per set language.
> 
> I added an "auto" abi.  This ended up being a little tricky because I 
> don't know the order in which the initializers get run, but this works.
> 
> In the process of doing this I got really annoyed that EVERYTHING was 
> done by copying structures around.  If we think that it is really 
> important to have the current_cp_abi be a structure rather than a 
> pointer to a structure so there was one less level of indirection, 
> that's fine.  But there is no reason to manage the internal list this 
> way as well.  So I changed cp_abis to be an array of pointers to 
> cp_abi_ops structures, and had to change the auto-grow mechanism to 
> account for it.
> 
> I also took out the extern def'ns of num_cp_abis, cp_abis and 
> current_cp_abi out of cp-abi.h.  They weren't currently used outside the 
> module, and if we end up needing to use them, we should provide 
> interfaces, rather than just poking around at the data.
> 
> I haven't written a doc note for this, I have run out of time for this 
> today, but thought I would give you a look before the day is out...

Better.  I have a couple of nits, but mostly I like it.  You've
probably thought of some of these; I realize it's a WIP.

I don't think you had to do anything nearly as complicated to the array
growth code, for one thing.  You could have simply grown it by sizeof
(struct cp_abi_ops *) instead of sizeof (struct cp_abi_ops) as it was
before.

> ! static struct cp_abi_ops current_cp_abi;

As in your other message... we can not assume anything about
initializer order.  This periodically makes me cry.

> ! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};
> 
> ! #define INITIAL_CP_ABI_MAX 8
> 
> ! static struct cp_abi_ops *orig_cp_abis[INITIAL_CP_ABI_MAX];
> ! static struct cp_abi_ops **cp_abis = orig_cp_abis;
> ! static int max_cp_abis = INITIAL_CP_ABI_MAX;

>   int
> ! register_cp_abi (struct cp_abi_ops *abi)
> ! {
> !   if (num_cp_abis == max_cp_abis)
>       {
> !       struct cp_abi_ops **new_abi_list;
> !       int i;
> !
> !       max_cp_abis *= 2;
> !       new_abi_list = (struct cp_abi_ops **) xmalloc (max_cp_abis * 
> sizeof (struct cp_abi_ops *));
> !       for (i = 0; i < num_cp_abis; i++)
> !         new_abi_list[i] = cp_abis[i];
> !
> !       if (cp_abis != orig_cp_abis)
> !       xfree (cp_abis);
> !
> !       cp_abis = new_abi_list;
> !     }
> !
>     cp_abis[num_cp_abis++] = abi;
> 
>     return 1;
> 
>   }

No point in having all this complexity.  We could dynamically allocate
the array in the first place, or even use a linked list if that were
simpler.  I think an array of just pointers, managed the same way the
old array was, is fine.  A couple extra xreallocs are worth the
simplicity.

> + void
> + set_cp_abi_as_auto_default (struct cp_abi_ops *abi)
> + {
> +
> +   if (auto_cp_abi.longname != NULL)
> +     xfree (auto_cp_abi.longname);

Crash the first time you set an ABI, I think - auto_cp_abi.longname
points to "auto" in your rodata.  Did this survive on Darwin?

> +   auto_cp_abi.longname = (char *) xmalloc (11 + strlen 
> (abi->shortname));

11?  Oh, I see, "currently \0".  Please use a sizeof("blah") for this
sort of thing; magic numbers are bad.

> +   auto_cp_abi.is_destructor_name = abi->is_destructor_name;
> +   auto_cp_abi.is_constructor_name = abi->is_constructor_name;
> +   auto_cp_abi.is_vtable_name = abi->is_vtable_name;
> +   auto_cp_abi.is_operator_name = abi->is_operator_name;
> +   auto_cp_abi.virtual_fn_field = abi->virtual_fn_field;
> +   auto_cp_abi.rtti_type = abi->rtti_type;
> +   auto_cp_abi.baseclass_offset = abi->baseclass_offset;
> +
> +   /* Since we copy the current ABI into current_cp_abi instead of using
> +      a pointer, if auto is currently the default, we need to reset 
> it. */

Is there some way we could manage all this with pointers instead?  I
don't like having to copy this structure above.  It's just another bug
every time I add an ABI-specific method, of which I suspect I'll need a
few more.

> !   char *longname; /* These two can't be const, because I need to */
> !   char *doc;      /* change the name for the auto abi. */

Then perhaps the name of the currently selected auto ABI should be
stored somewhere else... that should be simpler.

>             const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
>             if (name[0] == '_' && name[1] == 'Z')
>               {
> +               if (cp_abi_is_auto_p ())
>                   switch_to_cp_abi ("gnu-v3");
>                 break;
>               }

This bit, of course, is great :)

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-15 19:41         ` Daniel Jacobowitz
@ 2002-03-18 12:01           ` Jim Ingham
  2002-03-20 15:19             ` Daniel Jacobowitz
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-03-18 12:01 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel,

> On Fri, Mar 15, 2002 at 03:52:47PM -0800, Jim Ingham wrote:
>> Daniel,
>> 
>> Okay, how about this.
>> 
>> I changed the set/show as per set language.
>> 
>> I added an "auto" abi.  This ended up being a little tricky because I
>> don't know the order in which the initializers get run, but this works.
>> 
>> In the process of doing this I got really annoyed that EVERYTHING was
>> done by copying structures around.  If we think that it is really
>> important to have the current_cp_abi be a structure rather than a
>> pointer to a structure so there was one less level of indirection,
>> that's fine.  But there is no reason to manage the internal list this
>> way as well.  So I changed cp_abis to be an array of pointers to
>> cp_abi_ops structures, and had to change the auto-grow mechanism to
>> account for it.
>> 
>> I also took out the extern def'ns of num_cp_abis, cp_abis and
>> current_cp_abi out of cp-abi.h.  They weren't currently used outside the
>> module, and if we end up needing to use them, we should provide
>> interfaces, rather than just poking around at the data.
>> 
>> I haven't written a doc note for this, I have run out of time for this
>> today, but thought I would give you a look before the day is out...
> 
> Better.  I have a couple of nits, but mostly I like it.  You've
> probably thought of some of these; I realize it's a WIP.
> 
> I don't think you had to do anything nearly as complicated to the array
> growth code, for one thing.  You could have simply grown it by sizeof
> (struct cp_abi_ops *) instead of sizeof (struct cp_abi_ops) as it was
> before.

Okay, this was the standard trope in Tcl-land for what to do with an array
that you really didn't think was going to change in size, but just in case,
so I didn't think it was so complicated...

In fact, since the ABI's are all added in _initialize functions, it would be
even simpler just to fix the size of the array.  When somebody adds the
"last straw" ABI to gdb, we can just spit out a message saying increase this
number, and that developer can do so and recompile.  This is safe since I
don't think we really have the intention that we are adding these things
dynamically at runtime...

> 
>> ! static struct cp_abi_ops current_cp_abi;
> 
> As in your other message... we can not assume anything about
> initializer order.  This periodically makes me cry.

Yeah, I particularly like the bit where we initialize the mi twice, just to
make sure it ends up at the end of the list!

> 
>> ! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};
>> 
>> ! #define INITIAL_CP_ABI_MAX 8
>> 
>> ! static struct cp_abi_ops *orig_cp_abis[INITIAL_CP_ABI_MAX];
>> ! static struct cp_abi_ops **cp_abis = orig_cp_abis;
>> ! static int max_cp_abis = INITIAL_CP_ABI_MAX;
> 
>>   int
>> ! register_cp_abi (struct cp_abi_ops *abi)
>> ! {
>> !   if (num_cp_abis == max_cp_abis)
>>       {
>> !       struct cp_abi_ops **new_abi_list;
>> !       int i;
>> !
>> !       max_cp_abis *= 2;
>> !       new_abi_list = (struct cp_abi_ops **) xmalloc (max_cp_abis *
>> sizeof (struct cp_abi_ops *));
>> !       for (i = 0; i < num_cp_abis; i++)
>> !         new_abi_list[i] = cp_abis[i];
>> !
>> !       if (cp_abis != orig_cp_abis)
>> !       xfree (cp_abis);
>> !
>> !       cp_abis = new_abi_list;
>> !     }
>> !
>>     cp_abis[num_cp_abis++] = abi;
>> 
>>     return 1;
>> 
>>   }
> 
> No point in having all this complexity.  We could dynamically allocate
> the array in the first place, or even use a linked list if that were
> simpler.  I think an array of just pointers, managed the same way the
> old array was, is fine.  A couple extra xreallocs are worth the
> simplicity.

I vote for just fixing the size, then.  The ABIs are really fixed at build
time, and reallocing like in the original strikes me as ugly.

> 
>> + void
>> + set_cp_abi_as_auto_default (struct cp_abi_ops *abi)
>> + {
>> +
>> +   if (auto_cp_abi.longname != NULL)
>> +     xfree (auto_cp_abi.longname);
> 
> Crash the first time you set an ABI, I think - auto_cp_abi.longname
> points to "auto" in your rodata.  Did this survive on Darwin?
> 

Nah, cutting from too many windows at a time.  The patch below is right.

>> +   auto_cp_abi.longname = (char *) xmalloc (11 + strlen
>> (abi->shortname));
> 
> 11?  Oh, I see, "currently \0".  Please use a sizeof("blah") for this
> sort of thing; magic numbers are bad.
> 

OK.

>> +   auto_cp_abi.is_destructor_name = abi->is_destructor_name;
>> +   auto_cp_abi.is_constructor_name = abi->is_constructor_name;
>> +   auto_cp_abi.is_vtable_name = abi->is_vtable_name;
>> +   auto_cp_abi.is_operator_name = abi->is_operator_name;
>> +   auto_cp_abi.virtual_fn_field = abi->virtual_fn_field;
>> +   auto_cp_abi.rtti_type = abi->rtti_type;
>> +   auto_cp_abi.baseclass_offset = abi->baseclass_offset;
>> +
>> +   /* Since we copy the current ABI into current_cp_abi instead of using
>> +      a pointer, if auto is currently the default, we need to reset
>> it. */
> 
> Is there some way we could manage all this with pointers instead?  I
> don't like having to copy this structure above.  It's just another bug
> every time I add an ABI-specific method, of which I suspect I'll need a
> few more.
> 

I don't want to have the auto abi be a special beast off to one side.  This
seems to add to the complexity for no apparent reason.

We can more simply address your real objection by copying the whole
structure, then putting the strings back in place...  See the patch below.


>> !   char *longname; /* These two can't be const, because I need to */
>> !   char *doc;      /* change the name for the auto abi. */
> 
> Then perhaps the name of the currently selected auto ABI should be
> stored somewhere else... that should be simpler.

I disagree, it adds complexity to the actual code for the sake of
maintaining a few consts.  I don't think this is a good tradeoff.

> 
>>             const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
>>             if (name[0] == '_' && name[1] == 'Z')
>>               {
>> +               if (cp_abi_is_auto_p ())
>>                   switch_to_cp_abi ("gnu-v3");
>>                 break;
>>               }
> 
> This bit, of course, is great :)

Way too much work to get there, however.  Another point that is unclear to
me, should this instead be:

               if (cp_abi_is_auto_p ())
                   set_cp_abi_as_auto_default ("gnu_v3");
                 break;

I would have to change set_... to take the name rather than a structure, and
look it up (and add a lookup_cp_abi to be nice).  But it fits with the set
lang more.  OTOH, I have already spent more time on this that it deserves by
a long shot, so...

I am including a new patch, with just the cp-abi.c bits to keep it smaller,
and I didn't edit this one to change the indentation goofs that the mailer
added (I did with the last patch, oh fun...).

Jim

Index: cp-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 cp-abi.c
*** cp-abi.c    2002/01/04 18:20:19     1.3
--- cp-abi.c    2002/03/18 19:38:55
***************
*** 21,33 ****
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
  
! struct cp_abi_ops current_cp_abi;
  
! struct cp_abi_ops *cp_abis;
  
! int num_cp_abis = 0;
  
  enum ctor_kinds
  is_constructor_name (const char *name)
  {
--- 21,39 ----
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
+ #include "command.h"
+ #include "ui-out.h"
+ #include "gdbcmd.h"
  
! static struct cp_abi_ops current_cp_abi = {"", NULL};
! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};
  
! #define CP_ABI_MAX 8
  
! static struct cp_abi_ops *cp_abis[CP_ABI_MAX];
  
+ static int num_cp_abis = 0;
+ 
  enum ctor_kinds
  is_constructor_name (const char *name)
  {
*************** value_rtti_type (struct value *v, int *f
*** 87,109 ****
  }
  
  int
! register_cp_abi (struct cp_abi_ops abi)
  {
!   cp_abis =
!     xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
  int
  switch_to_cp_abi (const char *short_name)
  {
    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;
  }
  
--- 93,217 ----
  }
  
  int
! register_cp_abi (struct cp_abi_ops *abi)
! {
!   if (num_cp_abis == CP_ABI_MAX)
      {
!       error ("Too many CP ABI's, please increase CP_ABI_MAX in cp-abi.c");
!     }
!   
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
+ void
+ set_cp_abi_as_auto_default (struct cp_abi_ops *abi)
+ {
+ 
+   if (auto_cp_abi.longname != NULL)
+     xfree (auto_cp_abi.longname);
+ 
+   if (auto_cp_abi.doc != NULL)
+     xfree (auto_cp_abi.doc);
+ 
+   auto_cp_abi = *abi;
+ 
+   auto_cp_abi.shortname = "auto";
+   auto_cp_abi.longname = (char *) xmalloc (strlen ("currently ")
+                                          + strlen (abi->shortname));
+   sprintf (auto_cp_abi.longname, "currently %s",
+          abi->shortname);
+   
+   auto_cp_abi.doc = (char *) xmalloc (strlen ("currently ")
+                                     + strlen (abi->shortname));
+   sprintf (auto_cp_abi.doc, "currently %s",
+          abi->shortname);
+   
+   /* Since we copy the current ABI into current_cp_abi instead of using
+      a pointer, if auto is currently the default, we need to reset it. */
+                  
+   if (cp_abi_is_auto_p ())
+     switch_to_cp_abi ("auto");
+ }
+ 
+ int
+ cp_abi_is_auto_p ()
+ {
+   if (strcmp (current_cp_abi.shortname, "auto") == 0)
+     return 1;
+   else
+     return 0;
+ }
+ 
  int
  switch_to_cp_abi (const char *short_name)
  {
    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
+ show_cp_abis (int from_tty)
+ {
+   int i;
+   ui_out_text (uiout, "The available C++ ABIs 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_fmt (uiout, " - %s\n", cp_abis[i]->doc);
+     }
+   ui_out_tuple_end (uiout);
+ 
+ }
+ 
+ void
+ set_cp_abi_cmd (char *args, int from_tty)
+ {
+ 
+   if (args == NULL)
+     {
+       show_cp_abis (from_tty);
+       return;
+     }
+ 
+   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 currently selected C++ abi is: ");
+  
+   ui_out_field_string (uiout, "cp-abi", current_cp_abi.shortname);
+   ui_out_text (uiout, ".\n");
+ }
+ 
+ void
+ _initialize_cp_abi (void)
+ {
+   struct cmd_list_element *cmd;
+ 
+   register_cp_abi (&auto_cp_abi);
+   switch_to_cp_abi ("auto");
+ 
+   cmd = add_cmd ("cp-abi", class_obscure , set_cp_abi_cmd,
+                "Set the ABI used for inspecting C++ objects.\n\
+ \"set cp-abi\" with no arguments will list the available ABIs.",
&setlist);
+ 
+   cmd = add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd,
+                "Show the ABI used for inspecting C++ objects.",
&showlist);
+ 
+ }


-- 
++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=
Jim Ingham                              jingham@apple.com
Developer Tools - gdb


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-18 12:01           ` Jim Ingham
@ 2002-03-20 15:19             ` Daniel Jacobowitz
  2002-03-20 19:02               ` Jim Ingham
  0 siblings, 1 reply; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-20 15:19 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Mon, Mar 18, 2002 at 12:01:04PM -0800, Jim Ingham wrote:
> In fact, since the ABI's are all added in _initialize functions, it would be
> even simpler just to fix the size of the array.  When somebody adds the
> "last straw" ABI to gdb, we can just spit out a message saying increase this
> number, and that developer can do so and recompile.  This is safe since I
> don't think we really have the intention that we are adding these things
> dynamically at runtime...

Definitely not as GDB stands, and I don't see a point.  This bit is
fine.

> > 
> >>             const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
> >>             if (name[0] == '_' && name[1] == 'Z')
> >>               {
> >> +               if (cp_abi_is_auto_p ())
> >>                   switch_to_cp_abi ("gnu-v3");
> >>                 break;
> >>               }
> > 
> > This bit, of course, is great :)
> 
> Way too much work to get there, however.  Another point that is unclear to
> me, should this instead be:
> 
>                if (cp_abi_is_auto_p ())
>                    set_cp_abi_as_auto_default ("gnu_v3");
>                  break;
> 
> I would have to change set_... to take the name rather than a structure, and
> look it up (and add a lookup_cp_abi to be nice).  But it fits with the set
> lang more.  OTOH, I have already spent more time on this that it deserves by
> a long shot, so...

I suppose that this would be best; if we set cp-abi to auto it should
remain v3.

> I am including a new patch, with just the cp-abi.c bits to keep it smaller,
> and I didn't edit this one to change the indentation goofs that the mailer
> added (I did with the last patch, oh fun...).

Mangled patches are a pain to read.  If you can't get a mailer that
won't mangle it inline, can you at least get them attached in some
vaguely sane MIME-ish way?

Other than set_cp_abi_as_auto_default, my only remaining nits are
grammatical again:
!       error ("Too many CP ABI's, please increase CP_ABI_MAX in cp-abi.c");

internal_error(), and "C++ ABIs".

+   if (!switch_to_cp_abi (args))
+     error ("Could not find ABI: \"%s\" in ABI list\n", args);

"Could not find \"%s\" in ABI list" (and no \n)

+   ui_out_text (uiout, "The currently selected C++ abi is: ");

"ABI", not "abi".

And show_cp_abis should probably mention "auto".

With the above changes it should be OK, although I would like to see
it.  Thanks for following this through.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-20 15:19             ` Daniel Jacobowitz
@ 2002-03-20 19:02               ` Jim Ingham
  2002-03-22 10:34                 ` Daniel Jacobowitz
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-03-20 19:02 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 3400 bytes --]

Daniel,

On Wednesday, March 20, 2002, at 03:18  PM, Daniel Jacobowitz wrote:

> On Mon, Mar 18, 2002 at 12:01:04PM -0800, Jim Ingham wrote:
>> In fact, since the ABI's are all added in _initialize functions, it 
>> would be
>> even simpler just to fix the size of the array.  When somebody adds the
>> "last straw" ABI to gdb, we can just spit out a message saying 
>> increase this
>> number, and that developer can do so and recompile.  This is safe 
>> since I
>> don't think we really have the intention that we are adding these 
>> things
>> dynamically at runtime...
>
> Definitely not as GDB stands, and I don't see a point.  This bit is
> fine.

Groovy.

>
>>>
>>>>             const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
>>>>             if (name[0] == '_' && name[1] == 'Z')
>>>>               {
>>>> +               if (cp_abi_is_auto_p ())
>>>>                   switch_to_cp_abi ("gnu-v3");
>>>>                 break;
>>>>               }
>>>
>>> This bit, of course, is great :)
>>
>> Way too much work to get there, however.  Another point that is 
>> unclear to
>> me, should this instead be:
>>
>>                if (cp_abi_is_auto_p ())
>>                    set_cp_abi_as_auto_default ("gnu_v3");
>>                  break;
>>
>> I would have to change set_... to take the name rather than a 
>> structure, and
>> look it up (and add a lookup_cp_abi to be nice).  But it fits with the 
>> set
>> lang more.  OTOH, I have already spent more time on this that it 
>> deserves by
>> a long shot, so...
>
> I suppose that this would be best; if we set cp-abi to auto it should
> remain v3.

I can't tell which option you mean here, but I think you mean we should 
register v3 as auto.  Assuming that is true, I fixed the code to do 
that.  I also changed the "show cp-abi" output to also put out
the doc string, since in the auto case this is much more helpful.  Now 
you see, for instance:

(gdb) show cp-abi
The currently selected C++ ABI is: auto - currently gnu-v3.

which is more informative.

>
>> I am including a new patch, with just the cp-abi.c bits to keep it 
>> smaller,
>> and I didn't edit this one to change the indentation goofs that the 
>> mailer
>> added (I did with the last patch, oh fun...).
>
> Mangled patches are a pain to read.  If you can't get a mailer that
> won't mangle it inline, can you at least get them attached in some
> vaguely sane MIME-ish way?
>
> Other than set_cp_abi_as_auto_default, my only remaining nits are
> grammatical again:
> !       error ("Too many CP ABI's, please increase CP_ABI_MAX in cp-
> abi.c");
>
> internal_error(), and "C++ ABIs".

Yeah, I figured this out about 5 seconds after hitting send.

>
> +   if (!switch_to_cp_abi (args))
> +     error ("Could not find ABI: \"%s\" in ABI list\n", args);
>
> "Could not find \"%s\" in ABI list" (and no \n)
>
> +   ui_out_text (uiout, "The currently selected C++ abi is: ");
>
> "ABI", not "abi".

Okay.

>
> And show_cp_abis should probably mention "auto".

It does viz:

(gdb) set cp-abi
The available C++ ABIs are:
gnu-v2 - G++ Version 2 ABI
gnu-v3 - G++ Version 3 ABI
hpaCC - HP aCC ABI
auto - currently gnu-v2

That is part of the point of adding a real auto to the ABI list...

>
> With the above changes it should be OK, although I would like to see
> it.  Thanks for following this through.

Okay, let's see what Mail.app thinks is an attachment...

Jim


[-- Attachment #2: cp-abi.diff --]
[-- Type: application/octet-stream, Size: 8903 bytes --]

? .gdb_history
Index: cp-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 cp-abi.c
*** cp-abi.c	2002/01/04 18:20:19	1.3
--- cp-abi.c	2002/03/21 02:56:50
***************
*** 21,33 ****
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
  
! struct cp_abi_ops current_cp_abi;
  
! struct cp_abi_ops *cp_abis;
  
! int num_cp_abis = 0;
  
  enum ctor_kinds
  is_constructor_name (const char *name)
  {
--- 21,41 ----
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
+ #include "command.h"
+ #include "ui-out.h"
+ #include "gdbcmd.h"
  
! static struct cp_abi_ops *find_cp_abi (const char *short_name);
  
! static struct cp_abi_ops current_cp_abi = {"", NULL};
! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};
  
! #define CP_ABI_MAX 8
  
+ static struct cp_abi_ops *cp_abis[CP_ABI_MAX];
+ 
+ static int num_cp_abis = 0;
+ 
  enum ctor_kinds
  is_constructor_name (const char *name)
  {
*************** value_rtti_type (struct value *v, int *f
*** 87,109 ****
  }
  
  int
! register_cp_abi (struct cp_abi_ops abi)
  {
!   cp_abis =
!     xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
  int
! switch_to_cp_abi (const char *short_name)
  {
    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;
  }
  
--- 95,240 ----
  }
  
  int
! register_cp_abi (struct cp_abi_ops *abi)
  {
!   if (num_cp_abis == CP_ABI_MAX) 
!     {
!       internal_error (__FILE__, __LINE__,
! 		      "Too many CP ABIs, please increase CP_ABI_MAX in cp-abi.c");
!     }
!   
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
+ void
+ set_cp_abi_as_auto_default (const char *short_name)
+ {
+   struct cp_abi_ops *abi = find_cp_abi (short_name);
+   if (abi == NULL)
+     internal_error (__FILE__, __LINE__,
+ 		    "Cannot find C++ ABI \"%s\" to set it as auto default.",
+ 		    short_name);
+ 
+   if (auto_cp_abi.longname != NULL)
+     xfree (auto_cp_abi.longname);
+ 
+   if (auto_cp_abi.doc != NULL)
+     xfree (auto_cp_abi.doc);
+ 
+   auto_cp_abi = *abi;
+ 
+   auto_cp_abi.shortname = "auto";
+   auto_cp_abi.longname = (char *) xmalloc (strlen ("currently ")
+ 					   + strlen (abi->shortname));
+   sprintf (auto_cp_abi.longname, "currently %s", 
+ 	   abi->shortname);
+   
+   auto_cp_abi.doc = (char *) xmalloc (strlen ("currently ")
+ 				      + strlen (abi->shortname));
+   sprintf (auto_cp_abi.doc, "currently %s", 
+ 	   abi->shortname);
+   
+   /* Since we copy the current ABI into current_cp_abi instead of using
+      a pointer, if auto is currently the default, we need to reset it. */
+ 									  
+   if (cp_abi_is_auto_p ())
+     switch_to_cp_abi ("auto");
+ }
+ 
  int
! cp_abi_is_auto_p ()
  {
+   if (strcmp (current_cp_abi.shortname, "auto") == 0)
+     return 1;
+   else
+     return 0;
+ }
+ 
+ static struct cp_abi_ops *
+ find_cp_abi (const char *short_name)
+ {
    int i;
+ 
    for (i = 0; i < num_cp_abis; i++)
!     if (strcmp (cp_abis[i]->shortname, short_name) == 0)
!       {
! 	return cp_abis[i];
!       }
!   
!   return NULL;
! }
! 
! int
! switch_to_cp_abi (const char *short_name)
! {
!   struct cp_abi_ops *abi;
!   
!   abi = find_cp_abi (short_name);
!   if (abi == NULL)
!     return 0;
!   
!   current_cp_abi = *abi;
    return 1;
+   
+ }
+ 
+ void
+ show_cp_abis (int from_tty)
+ {
+   int i;
+   ui_out_text (uiout, "The available C++ ABIs 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_fmt (uiout, " - %s\n", cp_abis[i]->doc); 
+     }
+   ui_out_tuple_end (uiout);
+   
  }
  
+ void
+ set_cp_abi_cmd (char *args, int from_tty)
+ {
+   
+   if (args == NULL)
+     {
+       show_cp_abis (from_tty);
+       return;
+     }
+   
+   if (!switch_to_cp_abi (args))
+     error ("Could not find \"%s\" in ABI list", args);
+ }
+ 
+ void
+ show_cp_abi_cmd (char *args, int from_tty)
+ {
+   ui_out_text (uiout, "The currently selected C++ ABI is: ");
+   
+   ui_out_field_string (uiout, "cp-abi", current_cp_abi.shortname);
+   ui_out_text (uiout, " - ");
+   ui_out_field_string (uiout, "doc", current_cp_abi.doc);
+   ui_out_text (uiout, ".\n");
+ }
+ 
+ void
+ _initialize_cp_abi (void)
+ {
+   struct cmd_list_element *cmd;
+   
+   register_cp_abi (&auto_cp_abi);
+   switch_to_cp_abi ("auto");
+   
+   cmd = add_cmd ("cp-abi", class_obscure , set_cp_abi_cmd, 
+ 		 "Set the ABI used for inspecting C++ objects.\n\
+ \"set cp-abi\" with no arguments will list the available ABIs.", &setlist);
+   
+   cmd = add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd, 
+ 		 "Show the ABI used for inspecting C++ objects.", &showlist);
+   
+ }
Index: cp-abi.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.h,v
retrieving revision 1.4
diff -c -w -p -r1.4 cp-abi.h
*** cp-abi.h	2002/01/04 18:20:19	1.4
--- cp-abi.h	2002/03/21 02:56:50
*************** extern int baseclass_offset (struct type
*** 146,153 ****
  struct cp_abi_ops
  {
    const char *shortname;
!   const char *longname;
!   const char *doc;
  
    /* ABI-specific implementations for the functions declared above.  */
    enum ctor_kinds (*is_constructor_name) (const char *name);
--- 146,153 ----
  struct cp_abi_ops
  {
    const char *shortname;
!   char *longname; /* These two can't be const, because I need to */
!   char *doc;      /* change the name for the auto abi. */   
  
    /* ABI-specific implementations for the functions declared above.  */
    enum ctor_kinds (*is_constructor_name) (const char *name);
*************** struct cp_abi_ops
*** 163,173 ****
  };
  
  
! extern struct cp_abi_ops *cp_abis;
! extern int num_cp_abis;
! extern struct cp_abi_ops current_cp_abi;
! extern int register_cp_abi (struct cp_abi_ops abi);
  extern int switch_to_cp_abi (const char *short_name);
  
  #endif
  
--- 163,172 ----
  };
  
  
! extern int register_cp_abi (struct cp_abi_ops *abi);
  extern int switch_to_cp_abi (const char *short_name);
+ extern void set_cp_abi_as_auto_default (const char *short_name);
+ extern int cp_abi_is_auto_p ();
  
  #endif
  
Index: gnu-v2-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v2-abi.c,v
retrieving revision 1.6
diff -c -w -p -r1.6 gnu-v2-abi.c
*** gnu-v2-abi.c	2002/01/04 18:20:19	1.6
--- gnu-v2-abi.c	2002/03/21 02:56:50
*************** void
*** 424,429 ****
  _initialize_gnu_v2_abi (void)
  {
    init_gnuv2_ops ();
!   register_cp_abi (gnu_v2_abi_ops);
!   switch_to_cp_abi ("gnu-v2");
  }
--- 424,429 ----
  _initialize_gnu_v2_abi (void)
  {
    init_gnuv2_ops ();
!   register_cp_abi (&gnu_v2_abi_ops);
!   set_cp_abi_as_auto_default (gnu_v2_abi_ops.shortname);
  }
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.8
diff -c -w -p -r1.8 gnu-v3-abi.c
*** gnu-v3-abi.c	2002/02/02 00:04:46	1.8
--- gnu-v3-abi.c	2002/03/21 02:56:50
*************** _initialize_gnu_v3_abi (void)
*** 430,434 ****
  {
    init_gnuv3_ops ();
  
!   register_cp_abi (gnu_v3_abi_ops);
  }
--- 430,434 ----
  {
    init_gnuv3_ops ();
  
!   register_cp_abi (&gnu_v3_abi_ops);
  }
Index: hpacc-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/hpacc-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 hpacc-abi.c
*** hpacc-abi.c	2002/01/04 18:20:19	1.3
--- hpacc-abi.c	2002/03/21 02:56:50
*************** _initialize_hpacc_abi (void)
*** 324,328 ****
    regcomp (&operator_pattern,
  	   "^This will never match anything, please fill it in$", REG_NOSUB);
  
!   register_cp_abi (hpacc_abi_ops);
  }
--- 324,328 ----
    regcomp (&operator_pattern,
  	   "^This will never match anything, please fill it in$", REG_NOSUB);
  
!   register_cp_abi (&hpacc_abi_ops);
  }
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.19
diff -c -w -p -r1.19 minsyms.c
*** minsyms.c	2001/12/10 22:04:10	1.19
--- minsyms.c	2002/03/21 02:56:50
*************** install_minimal_symbols (struct objfile 
*** 970,976 ****
  	    const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
  	    if (name[0] == '_' && name[1] == 'Z')
  	      {
! 		switch_to_cp_abi ("gnu-v3");
  		break;
  	      }
  	  }
--- 970,977 ----
  	    const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
  	    if (name[0] == '_' && name[1] == 'Z')
  	      {
! 		if (cp_abi_is_auto_p ())
! 		  set_cp_abi_as_auto_default ("gnu-v3");
  		break;
  	      }
  	  }

[-- Attachment #3: Type: text/plain, Size: 105 bytes --]



--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-20 19:02               ` Jim Ingham
@ 2002-03-22 10:34                 ` Daniel Jacobowitz
  2002-03-22 11:04                   ` Andrew Cagney
  0 siblings, 1 reply; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-22 10:34 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Wed, Mar 20, 2002 at 07:01:53PM -0800, Jim Ingham wrote:
> >With the above changes it should be OK, although I would like to see
> >it.  Thanks for following this through.
> 
> Okay, let's see what Mail.app thinks is an attachment...

Not too bad, although I wish it knew how to mark them inline... in any
case, if you'll fix two tiny things this is approved.

!   char *longname; /* These two can't be const, because I need to */
!   char *doc;      /* change the name for the auto abi. */   

Comment formatting is against the GNU standard... I'd rather you just
kill the comment.

+                "Set the ABI used for inspecting C++ objects.\n\
+ \"set cp-abi\" with no arguments will list the available ABIs.", &setlist);

Replace with:
+                "Set the ABI used for inspecting C++ objects.\n"
+ 		 "\"set cp-abi\" with no arguments will list the available ABIs.",
+		 &setlist);

(or something like that; eliminating the \-return, which gcc3 I thought
would warn about...)

OK to commit with those changes.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-22 10:34                 ` Daniel Jacobowitz
@ 2002-03-22 11:04                   ` Andrew Cagney
  2002-03-22 11:09                     ` Daniel Jacobowitz
  0 siblings, 1 reply; 25+ messages in thread
From: Andrew Cagney @ 2002-03-22 11:04 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Jim Ingham, gdb-patches


> (or something like that; eliminating the \-return, which gcc3 I thought
> would warn about...)

FYI,  gcc has problems with:

	this is a string
that goes across several lines.

but not:

	this is a string\n\
that goes across several lines

enjoy,
Andrew




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-22 11:04                   ` Andrew Cagney
@ 2002-03-22 11:09                     ` Daniel Jacobowitz
  2002-03-22 11:29                       ` Jim Ingham
  2002-04-09 17:27                       ` Jim Ingham
  0 siblings, 2 replies; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-03-22 11:09 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Jim Ingham, gdb-patches

On Fri, Mar 22, 2002 at 02:04:08PM -0500, Andrew Cagney wrote:
> 
> >(or something like that; eliminating the \-return, which gcc3 I thought
> >would warn about...)
> 
> FYI,  gcc has problems with:
> 
> 	this is a string
> that goes across several lines.
> 
> but not:
> 
> 	this is a string\n\
> that goes across several lines

Oh, that was it.  In any case, I prefer using implicit string
concatenation, since it doesn't mess up indentation as much.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-22 11:09                     ` Daniel Jacobowitz
@ 2002-03-22 11:29                       ` Jim Ingham
  2002-04-09 17:27                       ` Jim Ingham
  1 sibling, 0 replies; 25+ messages in thread
From: Jim Ingham @ 2002-03-22 11:29 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Andrew Cagney, gdb-patches


On Friday, March 22, 2002, at 11:09  AM, Daniel Jacobowitz wrote:

> On Fri, Mar 22, 2002 at 02:04:08PM -0500, Andrew Cagney wrote:
>>
>>> (or something like that; eliminating the \-return, which gcc3 I 
>>> thought
>>> would warn about...)
>>
>> FYI,  gcc has problems with:
>>
>> 	this is a string
>> that goes across several lines.
>>
>> but not:
>>
>> 	this is a string\n\
>> that goes across several lines

Right, this one was the version that was always sure to work...

>
> Oh, that was it.  In any case, I prefer using implicit string
> concatenation, since it doesn't mess up indentation as much.

Not a problem.  There must have been some compiler from back in my dim 
past that choked on the implicit concatenation, 'cause whenever I see it 
it still sends chills up my spine.  But since I can't even remember 
when & where, and it is somewhat more readable, I can go with it.

Now for the texinfo change...

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-03-22 11:09                     ` Daniel Jacobowitz
  2002-03-22 11:29                       ` Jim Ingham
@ 2002-04-09 17:27                       ` Jim Ingham
  2002-04-09 17:54                         ` Daniel Jacobowitz
  2002-04-09 22:33                         ` Eli Zaretskii
  1 sibling, 2 replies; 25+ messages in thread
From: Jim Ingham @ 2002-04-09 17:27 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

I got distracted from this for a little while...  Here is a final 
version with something in the texi file as well.

ChangeLog:

2002-03-12  James Ingham <jingham@apple.com>

         * cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd,): New functions,
         allow you to set & show cplus abi's in case gdb gets it wrong.
         (set_cp_abi_as_auto_default): New function, set the "auto" abi
         to be this abi.
         (is_cp_abi_auto_p): New function, say whether the current abi
         is the default or not.
         (_initialize_cp_abi): Define the cp-abi switching commands.
         * cp-abi.h: declare the new functions.
         * minsyms.c (install_minimal_symbols): don't switch the cp_abi
         unless the current abi is auto.
         * gnu-v2-abi.c (_initialize_gnu_v2_abi): don't switch to gnu-v2,
         but set it as the auto_default instead.

Okay to check in?


[-- Attachment #2: cp-abi.patch --]
[-- Type: application/octet-stream, Size: 9940 bytes --]

Index: cp-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 cp-abi.c
*** cp-abi.c	4 Jan 2002 18:20:19 -0000	1.3
--- cp-abi.c	10 Apr 2002 00:23:40 -0000
***************
*** 21,32 ****
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
  
! struct cp_abi_ops current_cp_abi;
  
! struct cp_abi_ops *cp_abis;
  
! int num_cp_abis = 0;
  
  enum ctor_kinds
  is_constructor_name (const char *name)
--- 21,40 ----
  #include "defs.h"
  #include "value.h"
  #include "cp-abi.h"
+ #include "command.h"
+ #include "ui-out.h"
+ #include "gdbcmd.h"
  
! static struct cp_abi_ops *find_cp_abi (const char *short_name);
  
! static struct cp_abi_ops current_cp_abi = {"", NULL};
! static struct cp_abi_ops auto_cp_abi = {"auto", NULL};
  
! #define CP_ABI_MAX 8
! 
! static struct cp_abi_ops *cp_abis[CP_ABI_MAX];
! 
! static int num_cp_abis = 0;
  
  enum ctor_kinds
  is_constructor_name (const char *name)
*************** value_rtti_type (struct value *v, int *f
*** 87,109 ****
  }
  
  int
! register_cp_abi (struct cp_abi_ops abi)
  {
!   cp_abis =
!     xrealloc (cp_abis, (num_cp_abis + 1) * sizeof (struct cp_abi_ops));
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
  int
! switch_to_cp_abi (const char *short_name)
  {
    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;
  }
  
--- 95,242 ----
  }
  
  int
! register_cp_abi (struct cp_abi_ops *abi)
  {
!   if (num_cp_abis == CP_ABI_MAX) 
!     {
!       internal_error (__FILE__, __LINE__,
! 		      "Too many CP ABIs, please increase CP_ABI_MAX in cp-abi.c");
!     }
!   
    cp_abis[num_cp_abis++] = abi;
  
    return 1;
  
  }
  
+ void
+ set_cp_abi_as_auto_default (const char *short_name)
+ {
+   struct cp_abi_ops *abi = find_cp_abi (short_name);
+   if (abi == NULL)
+     internal_error (__FILE__, __LINE__,
+ 		    "Cannot find C++ ABI \"%s\" to set it as auto default.",
+ 		    short_name);
+ 
+   if (auto_cp_abi.longname != NULL)
+     xfree (auto_cp_abi.longname);
+ 
+   if (auto_cp_abi.doc != NULL)
+     xfree (auto_cp_abi.doc);
+ 
+   auto_cp_abi = *abi;
+ 
+   auto_cp_abi.shortname = "auto";
+   auto_cp_abi.longname = (char *) xmalloc (strlen ("currently ")
+ 					   + strlen (abi->shortname));
+   sprintf (auto_cp_abi.longname, "currently %s", 
+ 	   abi->shortname);
+   
+   auto_cp_abi.doc = (char *) xmalloc (strlen ("currently ")
+ 				      + strlen (abi->shortname));
+   sprintf (auto_cp_abi.doc, "currently %s", 
+ 	   abi->shortname);
+   
+   /* Since we copy the current ABI into current_cp_abi instead of using
+      a pointer, if auto is currently the default, we need to reset it. */
+ 									  
+   if (cp_abi_is_auto_p ())
+     switch_to_cp_abi ("auto");
+ }
+ 
  int
! cp_abi_is_auto_p ()
! {
!   if (strcmp (current_cp_abi.shortname, "auto") == 0)
!     return 1;
!   else
!     return 0;
! }
! 
! static struct cp_abi_ops *
! find_cp_abi (const char *short_name)
  {
    int i;
+ 
    for (i = 0; i < num_cp_abis; i++)
!     if (strcmp (cp_abis[i]->shortname, short_name) == 0)
!       {
! 	return cp_abis[i];
!       }
! 
!   return NULL;
! }
! 
! int
! switch_to_cp_abi (const char *short_name)
! {
!   struct cp_abi_ops *abi;
!   
!   abi = find_cp_abi (short_name);
!   if (abi == NULL)
!     return 0;
! 
!   current_cp_abi = *abi;
    return 1;
+   
+ }
+ 
+ void
+ show_cp_abis (int from_tty)
+ {
+   int i;
+   ui_out_text (uiout, "The available C++ ABIs 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_fmt (uiout, " - %s\n", cp_abis[i]->doc); 
+     }
+   ui_out_tuple_end (uiout);
+ 
  }
  
+ void
+ set_cp_abi_cmd (char *args, int from_tty)
+ {
+ 
+   if (args == NULL)
+     {
+       show_cp_abis (from_tty);
+       return;
+     }
+ 
+   if (!switch_to_cp_abi (args))
+     error ("Could not find \"%s\" in ABI list", args);
+ }
+ 
+ void
+ show_cp_abi_cmd (char *args, int from_tty)
+ {
+   ui_out_text (uiout, "The currently selected C++ ABI is: ");
+  
+   ui_out_field_string (uiout, "cp-abi", current_cp_abi.shortname);
+   ui_out_text (uiout, " - ");
+   ui_out_field_string (uiout, "doc", current_cp_abi.doc);
+   ui_out_text (uiout, ".\n");
+ }
+ 
+ void
+ _initialize_cp_abi (void)
+ {
+   struct cmd_list_element *cmd;
+ 
+   register_cp_abi (&auto_cp_abi);
+   switch_to_cp_abi ("auto");
+ 
+   cmd = add_cmd ("cp-abi", class_obscure , set_cp_abi_cmd, 
+ 		 "Set the ABI used for inspecting C++ objects.\n"
+ 		 "\"set cp-abi\" with no arguments will list the "
+ 		 "available ABIs.", 
+ 		 &setlist);
+ 
+   cmd = add_cmd ("cp-abi", class_obscure, show_cp_abi_cmd, 
+ 		 "Show the ABI used for inspecting C++ objects.", &showlist);
+ 
+ }
Index: cp-abi.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-abi.h,v
retrieving revision 1.4
diff -c -w -p -r1.4 cp-abi.h
*** cp-abi.h	4 Jan 2002 18:20:19 -0000	1.4
--- cp-abi.h	10 Apr 2002 00:23:40 -0000
*************** extern int baseclass_offset (struct type
*** 146,153 ****
  struct cp_abi_ops
  {
    const char *shortname;
!   const char *longname;
!   const char *doc;
  
    /* ABI-specific implementations for the functions declared above.  */
    enum ctor_kinds (*is_constructor_name) (const char *name);
--- 146,153 ----
  struct cp_abi_ops
  {
    const char *shortname;
!   char *longname; /* These two can't be const, because I need to */
!   char *doc;      /* change the name for the auto abi. */   
  
    /* ABI-specific implementations for the functions declared above.  */
    enum ctor_kinds (*is_constructor_name) (const char *name);
*************** struct cp_abi_ops
*** 163,173 ****
  };
  
  
! extern struct cp_abi_ops *cp_abis;
! extern int num_cp_abis;
! extern struct cp_abi_ops current_cp_abi;
! extern int register_cp_abi (struct cp_abi_ops abi);
  extern int switch_to_cp_abi (const char *short_name);
  
  #endif
  
--- 163,172 ----
  };
  
  
! extern int register_cp_abi (struct cp_abi_ops *abi);
  extern int switch_to_cp_abi (const char *short_name);
+ extern void set_cp_abi_as_auto_default (const char *short_name);
+ extern int cp_abi_is_auto_p ();
  
  #endif
  
Index: gnu-v2-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v2-abi.c,v
retrieving revision 1.6
diff -c -w -p -r1.6 gnu-v2-abi.c
*** gnu-v2-abi.c	4 Jan 2002 18:20:19 -0000	1.6
--- gnu-v2-abi.c	10 Apr 2002 00:23:40 -0000
*************** void
*** 424,429 ****
  _initialize_gnu_v2_abi (void)
  {
    init_gnuv2_ops ();
!   register_cp_abi (gnu_v2_abi_ops);
!   switch_to_cp_abi ("gnu-v2");
  }
--- 424,429 ----
  _initialize_gnu_v2_abi (void)
  {
    init_gnuv2_ops ();
!   register_cp_abi (&gnu_v2_abi_ops);
!   set_cp_abi_as_auto_default (gnu_v2_abi_ops.shortname);
  }
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.8
diff -c -w -p -r1.8 gnu-v3-abi.c
*** gnu-v3-abi.c	2 Feb 2002 00:04:46 -0000	1.8
--- gnu-v3-abi.c	10 Apr 2002 00:23:40 -0000
*************** _initialize_gnu_v3_abi (void)
*** 430,434 ****
  {
    init_gnuv3_ops ();
  
!   register_cp_abi (gnu_v3_abi_ops);
  }
--- 430,434 ----
  {
    init_gnuv3_ops ();
  
!   register_cp_abi (&gnu_v3_abi_ops);
  }
Index: hpacc-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/hpacc-abi.c,v
retrieving revision 1.3
diff -c -w -p -r1.3 hpacc-abi.c
*** hpacc-abi.c	4 Jan 2002 18:20:19 -0000	1.3
--- hpacc-abi.c	10 Apr 2002 00:23:40 -0000
*************** _initialize_hpacc_abi (void)
*** 324,328 ****
    regcomp (&operator_pattern,
  	   "^This will never match anything, please fill it in$", REG_NOSUB);
  
!   register_cp_abi (hpacc_abi_ops);
  }
--- 324,328 ----
    regcomp (&operator_pattern,
  	   "^This will never match anything, please fill it in$", REG_NOSUB);
  
!   register_cp_abi (&hpacc_abi_ops);
  }
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.20
diff -c -w -p -r1.20 minsyms.c
*** minsyms.c	19 Mar 2002 19:00:04 -0000	1.20
--- minsyms.c	10 Apr 2002 00:23:40 -0000
*************** install_minimal_symbols (struct objfile 
*** 960,966 ****
  	    const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
  	    if (name[0] == '_' && name[1] == 'Z')
  	      {
! 		switch_to_cp_abi ("gnu-v3");
  		break;
  	      }
  	  }
--- 960,967 ----
  	    const char *name = SYMBOL_NAME (&objfile->msymbols[i]);
  	    if (name[0] == '_' && name[1] == 'Z')
  	      {
! 		if (cp_abi_is_auto_p ())
! 		  set_cp_abi_as_auto_default ("gnu-v3");
  		break;
  	      }
  	  }
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.95
diff -c -w -p -r1.95 gdb.texinfo
*** doc/gdb.texinfo	7 Apr 2002 19:09:58 -0000	1.95
--- doc/gdb.texinfo	10 Apr 2002 00:23:40 -0000
*************** Do not pretty print C@t{++} virtual func
*** 5289,5294 ****
--- 5289,5308 ----
  Show whether C@t{++} virtual function tables are pretty printed, or not.
  @end table
  
+ @kindex set cp-abi
+ @item set cp-abi
+ @itemx set cp-abi auto
+ Set the C++ ABI that gdb will use to decode C++ objects.  The default is "auto"
+ which means gdb will assume the gnu-v2 ABI unless it sees symbols that
+ look like the gnu-v3 ABI, in which case it will switch to the gnu-v3 ABI.  With 
+ no arguments, list the available C++ ABIs.
+ 
+ 
+ @kindex show cp-abi
+ @item show cp-abi
+ Show which C++ ABI gdb uses to decode C++ objects.
+ 
+ 
  @node Value History
  @section Value history
  

[-- Attachment #3: Type: text/plain, Size: 808 bytes --]



Jim


On Friday, March 22, 2002, at 11:09  AM, Daniel Jacobowitz wrote:

> On Fri, Mar 22, 2002 at 02:04:08PM -0500, Andrew Cagney wrote:
>>
>>> (or something like that; eliminating the \-return, which gcc3 I 
>>> thought
>>> would warn about...)
>>
>> FYI,  gcc has problems with:
>>
>> 	this is a string
>> that goes across several lines.
>>
>> but not:
>>
>> 	this is a string\n\
>> that goes across several lines
>
> Oh, that was it.  In any case, I prefer using implicit string
> concatenation, since it doesn't mess up indentation as much.
>
> --
> Daniel Jacobowitz                           Carnegie Mellon University
> MontaVista Software                         Debian GNU/Linux Developer
>
>
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-09 17:27                       ` Jim Ingham
@ 2002-04-09 17:54                         ` Daniel Jacobowitz
  2002-04-10 11:10                           ` Jim Ingham
  2002-04-09 22:33                         ` Eli Zaretskii
  1 sibling, 1 reply; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-04-09 17:54 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Tue, Apr 09, 2002 at 05:27:19PM -0700, Jim Ingham wrote:
> I got distracted from this for a little while...  Here is a final 
> version with something in the texi file as well.
> 
> ChangeLog:
> 
> 2002-03-12  James Ingham <jingham@apple.com>
> 
>         * cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd,): New functions,
>         allow you to set & show cplus abi's in case gdb gets it wrong.
>         (set_cp_abi_as_auto_default): New function, set the "auto" abi
>         to be this abi.
>         (is_cp_abi_auto_p): New function, say whether the current abi
>         is the default or not.
>         (_initialize_cp_abi): Define the cp-abi switching commands.
>         * cp-abi.h: declare the new functions.
>         * minsyms.c (install_minimal_symbols): don't switch the cp_abi
>         unless the current abi is auto.
>         * gnu-v2-abi.c (_initialize_gnu_v2_abi): don't switch to gnu-v2,
>         but set it as the auto_default instead.
> 
> Okay to check in?

I think we may have misplaced a revision here...

!       internal_error (__FILE__, __LINE__,
!                     "Too many CP ABIs, please increase CP_ABI_MAX in cp-abi.c");

C++ ABIs.

!   char *longname; /* These two can't be const, because I need to */
!   char *doc;      /* change the name for the auto abi. */

GNU comment formatting.  Something like:
/* These two are not constant because they are changed at runtime
   for the auto ABI.  */
char *longname;
char *doc;


More importantly:
!               if (cp_abi_is_auto_p ())
!                 set_cp_abi_as_auto_default ("gnu-v3");

Shouldn't you lose the cp_abi_is_auto_p () check there?


If you agree with all three, feel free to update them and check it in.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-09 17:27                       ` Jim Ingham
  2002-04-09 17:54                         ` Daniel Jacobowitz
@ 2002-04-09 22:33                         ` Eli Zaretskii
  2002-04-10 11:14                           ` Jim Ingham
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2002-04-09 22:33 UTC (permalink / raw)
  To: Jim Ingham; +Cc: Daniel Jacobowitz, gdb-patches


On Tue, 9 Apr 2002, Jim Ingham wrote:

> I got distracted from this for a little while...  Here is a final 
> version with something in the texi file as well.

Thanks.  Some comments about the doco patch:

> + @kindex set cp-abi
> + @item set cp-abi
> + @itemx set cp-abi auto
> + Set the C++ ABI that gdb will use to decode C++ objects.  The default is "auto"
> + which means gdb will assume the gnu-v2 ABI unless it sees symbols that
> + look like the gnu-v3 ABI, in which case it will switch to the gnu-v3 ABI.  With 
> + no arguments, list the available C++ ABIs.

Please explain in a few words what "ABI" means; I don't think Joe Random 
C++ User will necessarily know that.  A list of possible values one can 
use (in addition to "auto") is also something the manual should have.

(Btw, I think that the built-in documentation of the "set abi" command 
could also use a word of explanation of the term "ABI".)

Please change "auto" to ``auto'' (this looks much prettier in the printed 
version, and is translated into "auto" in the Info output), and please 
use C@t{++} instead of C++ (also for aesthetic reasons).

Finally, we use `@value{GDBN}' instead of just `gdb' throughout the 
manual (evidently to allow custom versions of manuals for GDB that is 
named differently).


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-09 17:54                         ` Daniel Jacobowitz
@ 2002-04-10 11:10                           ` Jim Ingham
  2002-04-10 11:58                             ` Daniel Jacobowitz
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-04-10 11:10 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel,

Yup...  I hadn't carried over the last checkin from my apple gdb 
repository to my fsf copy.  Doh!...

On Tuesday, April 9, 2002, at 05:54  PM, Daniel Jacobowitz wrote:

> On Tue, Apr 09, 2002 at 05:27:19PM -0700, Jim Ingham wrote:
>> I got distracted from this for a little while...  Here is a final
>> version with something in the texi file as well.
>>
>> ChangeLog:
>>
>> 2002-03-12  James Ingham <jingham@apple.com>
>>
>>         * cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd,): New functions,
>>         allow you to set & show cplus abi's in case gdb gets it wrong.
>>         (set_cp_abi_as_auto_default): New function, set the "auto" abi
>>         to be this abi.
>>         (is_cp_abi_auto_p): New function, say whether the current abi
>>         is the default or not.
>>         (_initialize_cp_abi): Define the cp-abi switching commands.
>>         * cp-abi.h: declare the new functions.
>>         * minsyms.c (install_minimal_symbols): don't switch the cp_abi
>>         unless the current abi is auto.
>>         * gnu-v2-abi.c (_initialize_gnu_v2_abi): don't switch to 
>> gnu-v2,
>>         but set it as the auto_default instead.
>>
>> Okay to check in?
>
> I think we may have misplaced a revision here...
>
> !       internal_error (__FILE__, __LINE__,
> !                     "Too many CP ABIs, please increase CP_ABI_MAX in 
> cp-abi.c");
>
> C++ ABIs.
>
> !   char *longname; /* These two can't be const, because I need to */
> !   char *doc;      /* change the name for the auto abi. */
>
> GNU comment formatting.  Something like:
> /* These two are not constant because they are changed at runtime
>    for the auto ABI.  */
> char *longname;
> char *doc;

I think we agreed to just drop the comment here.  OK?

>
>
> More importantly:
> !               if (cp_abi_is_auto_p ())
> !                 set_cp_abi_as_auto_default ("gnu-v3");
>
> Shouldn't you lose the cp_abi_is_auto_p () check there?
>

This seems correct.

>
> If you agree with all three, feel free to update them and check it in.
>

Okay, need to fix the docs first, then...

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-09 22:33                         ` Eli Zaretskii
@ 2002-04-10 11:14                           ` Jim Ingham
  2002-04-11 12:25                             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Jim Ingham @ 2002-04-10 11:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Daniel Jacobowitz, gdb-patches


On Tuesday, April 9, 2002, at 11:31  PM, Eli Zaretskii wrote:

>
> On Tue, 9 Apr 2002, Jim Ingham wrote:
>
>> I got distracted from this for a little while...  Here is a final
>> version with something in the texi file as well.
>
> Thanks.  Some comments about the doco patch:
>
>> + @kindex set cp-abi
>> + @item set cp-abi
>> + @itemx set cp-abi auto
>> + Set the C++ ABI that gdb will use to decode C++ objects.  The 
>> default is "auto"
>> + which means gdb will assume the gnu-v2 ABI unless it sees symbols 
>> that
>> + look like the gnu-v3 ABI, in which case it will switch to the gnu-v3 
>> ABI.  With
>> + no arguments, list the available C++ ABIs.
>
> Please explain in a few words what "ABI" means; I don't think Joe Random
> C++ User will necessarily know that.  A list of possible values one can
> use (in addition to "auto") is also something the manual should have.

I not sure I agree with this.  First off, this "set" section doesn't 
explain what other similarly obscure terms mean (like "set vtable").  
These are expert features, so if you need them presumably you know what 
they are.  Also, the available types are dynamically generated.  The 
doc's tell you how to get the list, so it seems like actually listing 
the current possible values is just asking for the manual to get out of 
date...

>
> (Btw, I think that the built-in documentation of the "set abi" command
> could also use a word of explanation of the term "ABI".)
>
> Please change "auto" to ``auto'' (this looks much prettier in the 
> printed
> version, and is translated into "auto" in the Info output), and please
> use C@t{++} instead of C++ (also for aesthetic reasons).
>
> Finally, we use `@value{GDBN}' instead of just `gdb' throughout the
> manual (evidently to allow custom versions of manuals for GDB that is
> named differently).

Will do.

Jim
--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-10 11:10                           ` Jim Ingham
@ 2002-04-10 11:58                             ` Daniel Jacobowitz
  0 siblings, 0 replies; 25+ messages in thread
From: Daniel Jacobowitz @ 2002-04-10 11:58 UTC (permalink / raw)
  To: Jim Ingham; +Cc: gdb-patches

On Wed, Apr 10, 2002 at 11:10:27AM -0700, Jim Ingham wrote:
> Daniel,
> 
> Yup...  I hadn't carried over the last checkin from my apple gdb 
> repository to my fsf copy.  Doh!...
> 
> On Tuesday, April 9, 2002, at 05:54  PM, Daniel Jacobowitz wrote:
> 
> >On Tue, Apr 09, 2002 at 05:27:19PM -0700, Jim Ingham wrote:
> >>I got distracted from this for a little while...  Here is a final
> >>version with something in the texi file as well.
> >>
> >>ChangeLog:
> >>
> >>2002-03-12  James Ingham <jingham@apple.com>
> >>
> >>        * cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd,): New functions,
> >>        allow you to set & show cplus abi's in case gdb gets it wrong.
> >>        (set_cp_abi_as_auto_default): New function, set the "auto" abi
> >>        to be this abi.
> >>        (is_cp_abi_auto_p): New function, say whether the current abi
> >>        is the default or not.
> >>        (_initialize_cp_abi): Define the cp-abi switching commands.
> >>        * cp-abi.h: declare the new functions.
> >>        * minsyms.c (install_minimal_symbols): don't switch the cp_abi
> >>        unless the current abi is auto.
> >>        * gnu-v2-abi.c (_initialize_gnu_v2_abi): don't switch to 
> >>gnu-v2,
> >>        but set it as the auto_default instead.
> >>
> >>Okay to check in?
> >
> >I think we may have misplaced a revision here...
> >
> >!       internal_error (__FILE__, __LINE__,
> >!                     "Too many CP ABIs, please increase CP_ABI_MAX in 
> >cp-abi.c");
> >
> >C++ ABIs.
> >
> >!   char *longname; /* These two can't be const, because I need to */
> >!   char *doc;      /* change the name for the auto abi. */
> >
> >GNU comment formatting.  Something like:
> >/* These two are not constant because they are changed at runtime
> >   for the auto ABI.  */
> >char *longname;
> >char *doc;
> 
> I think we agreed to just drop the comment here.  OK?

Sure.

> >
> >
> >More importantly:
> >!               if (cp_abi_is_auto_p ())
> >!                 set_cp_abi_as_auto_default ("gnu-v3");
> >
> >Shouldn't you lose the cp_abi_is_auto_p () check there?
> >
> 
> This seems correct.

Glad we agree.

> 
> >
> >If you agree with all three, feel free to update them and check it in.
> >
> 
> Okay, need to fix the docs first, then...

Yep.  Non-doc parts are approved.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: add set cp-abi command
  2002-04-10 11:14                           ` Jim Ingham
@ 2002-04-11 12:25                             ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2002-04-11 12:25 UTC (permalink / raw)
  To: jingham; +Cc: drow, gdb-patches

> Date: Wed, 10 Apr 2002 11:14:13 -0700
> From: Jim Ingham <jingham@apple.com>
> 
> > Please explain in a few words what "ABI" means; I don't think Joe Random
> > C++ User will necessarily know that.  A list of possible values one can
> > use (in addition to "auto") is also something the manual should have.
> 
> I not sure I agree with this.  First off, this "set" section doesn't 
> explain what other similarly obscure terms mean (like "set vtable").  
> These are expert features, so if you need them presumably you know what 
> they are.

Nevertheless, I think it doesn't hurt to say something like this:

  Set the C@t{++} @dfn{ABI} (Application Binary Interface) that
  @value{GDBN} will use to decode C@t{++} objects.

> Also, the available types are dynamically generated.

Does it mean we don't know at least some of the possible values in
advance?  I'd be surprised.


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2002-04-11 19:25 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-13 10:56 add set cp-abi command Jim Ingham
2002-03-13 12:11 ` Eli Zaretskii
2002-03-13 12:11 ` Daniel Jacobowitz
2002-03-14 13:14   ` Jim Ingham
2002-03-14 13:26     ` Daniel Jacobowitz
2002-03-15 15:53       ` Jim Ingham
2002-03-15 19:41         ` Daniel Jacobowitz
2002-03-18 12:01           ` Jim Ingham
2002-03-20 15:19             ` Daniel Jacobowitz
2002-03-20 19:02               ` Jim Ingham
2002-03-22 10:34                 ` Daniel Jacobowitz
2002-03-22 11:04                   ` Andrew Cagney
2002-03-22 11:09                     ` Daniel Jacobowitz
2002-03-22 11:29                       ` Jim Ingham
2002-04-09 17:27                       ` Jim Ingham
2002-04-09 17:54                         ` Daniel Jacobowitz
2002-04-10 11:10                           ` Jim Ingham
2002-04-10 11:58                             ` Daniel Jacobowitz
2002-04-09 22:33                         ` Eli Zaretskii
2002-04-10 11:14                           ` Jim Ingham
2002-04-11 12:25                             ` Eli Zaretskii
2002-03-15 17:11       ` Jim Ingham
2002-03-14 15:29 ` Andrew Cagney
2002-03-15 10:33   ` Jim Ingham
2002-03-15 17:29     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox