2002-08-21 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / kod.c
index 0a90677746c39f5eb4d76c2dfe5ad16003dfab4e..8f565bb8c36ed7599fe031d6c65a7061504e6ab6 100644 (file)
--- a/gdb/kod.c
+++ b/gdb/kod.c
@@ -1,5 +1,5 @@
 /* Kernel Object Display generic routines and callbacks
-   Copyright 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
 
    Written by Fernando Nasser <fnasser@cygnus.com> for Cygnus Solutions.
 
@@ -132,7 +132,16 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
 {
   char *p;
 
-  if (command->type != set_cmd)
+  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
+     the set command passed as a parameter.  The clone operation will
+     include (BUG?) any ``set'' command callback, if present.
+     Commands like ``info set'' call all the ``show'' command
+     callbacks.  Unfortunatly, for ``show'' commands cloned from
+     ``set'', this includes callbacks belonging to ``set'' commands.
+     Making this worse, this only occures if add_show_from_set() is
+     called after add_cmd_sfunc() (BUG?).  */
+
+  if (cmd_type (command) != set_cmd)
     return;
 
   /* If we had already had an open OS, close it.  */
@@ -143,9 +152,8 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
   if (old_operating_system)
     {
       delete_cmd (old_operating_system, &infolist);
-      free (old_operating_system);
+      xfree (old_operating_system);
     }
-  old_operating_system = xstrdup (operating_system);
 
   if (! operating_system || ! *operating_system)
     {
@@ -160,6 +168,8 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
     {
       char *kodlib;
 
+      old_operating_system = xstrdup (operating_system);
+
       load_kod_library (operating_system);
 
       kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);
@@ -175,7 +185,7 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
        p = "Unknown KOD library";
       printf_filtered ("%s - %s\n", operating_system, p);
 
-      free (kodlib);
+      xfree (kodlib);
     }
 }
 
@@ -216,7 +226,7 @@ load_kod_library (char *lib)
 }
 
 void
-_initialize_kod ()
+_initialize_kod (void)
 {
   struct cmd_list_element *c;
 
@@ -224,6 +234,6 @@ _initialize_kod ()
                   (char *) &operating_system,
                   "Set operating system",
                   &setlist);
-  c->function.sfunc = kod_set_os;
+  set_cmd_sfunc (c, kod_set_os);
   add_show_from_set (c, &showlist);
 }
This page took 0.02926 seconds and 4 git commands to generate.