OSDN Git Service

2010-06-18 Stan Shebs <stan@codesourcery.com>
authorshebs <shebs>
Sat, 19 Jun 2010 08:06:29 +0000 (08:06 +0000)
committershebs <shebs>
Sat, 19 Jun 2010 08:06:29 +0000 (08:06 +0000)
* osdata.c (get_osdata): Warn separately if target does not report
type list.
(info_osdata_command): Allow empty type, report error if target
does not return available types of OS data.
* linux-nat.c (linux_nat_xfer_osdata): Report list of OS data
types if no annex supplied.

* gdb.texinfo (Operating System Auxiliary Information): Describe
"info os" when no arguments given.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/linux-nat.c
gdb/osdata.c

index fd43553..b8cd0f8 100644 (file)
@@ -1,5 +1,12 @@
 2010-06-18  Stan Shebs  <stan@codesourcery.com>
 
+       * osdata.c (get_osdata): Warn separately if target does not report
+       type list.
+       (info_osdata_command): Allow empty type, report error if target
+       does not return available types of OS data.
+       * linux-nat.c (linux_nat_xfer_osdata): Report list of OS data
+       types if no annex supplied.
+
        * thread.c (thread_id_make_value): Make a value representing the
        current thread.
        (_initialize_thread): Create $_thread.
index e853346..b93e4c8 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-18  Stan Shebs  <stan@codesourcery.com>
 
+       * gdb.texinfo (Operating System Auxiliary Information): Describe
+       "info os" when no arguments given.
+
        * gdb.texinfo (Debugging Programs with Multiple Threads): Describe
        $_thread.
 
index 8c19696..f361451 100644 (file)
@@ -8519,6 +8519,12 @@ this functionality depends on the remote stub's support of the
 @samp{qXfer:osdata:read} packet, see @ref{qXfer osdata read}.
 
 @table @code
+@kindex info os
+@item info os
+List the types of OS information available for the target.  If the
+target does not return a list of possible types, this command will
+report an error.
+
 @kindex info os processes
 @item info os processes
 Display the list of processes on the target.  For each process,
index 43370f0..93ba8e2 100644 (file)
@@ -4948,6 +4948,45 @@ linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
 
   gdb_assert (object == TARGET_OBJECT_OSDATA);
 
+  if (!annex)
+    {
+      if (offset == 0)
+       {
+         if (len_avail != -1 && len_avail != 0)
+           obstack_free (&obstack, NULL);
+         len_avail = 0;
+         buf = NULL;
+         obstack_init (&obstack);
+         obstack_grow_str (&obstack, "<osdata type=\"types\">\n");
+
+         obstack_xml_printf (
+                             &obstack,
+                             "<item>"
+                             "<column name=\"Type\">processes</column>"
+                             "<column name=\"Description\">Listing of all processes</column>"
+                             "</item>");
+
+         obstack_grow_str0 (&obstack, "</osdata>\n");
+         buf = obstack_finish (&obstack);
+         len_avail = strlen (buf);
+       }
+
+      if (offset >= len_avail)
+       {
+         /* Done.  Get rid of the obstack.  */
+         obstack_free (&obstack, NULL);
+         buf = NULL;
+         len_avail = 0;
+         return 0;
+       }
+
+      if (len > len_avail - offset)
+       len = len_avail - offset;
+      memcpy (readbuf, buf + offset, len);
+
+      return len;
+    }
+
   if (strcmp (annex, "processes") != 0)
     return 0;
 
index 3440b4e..76143bf 100644 (file)
@@ -256,7 +256,12 @@ get_osdata (const char *type)
       struct cleanup *old_chain = make_cleanup (xfree, xml);
 
       if (xml[0] == '\0')
-       warning (_("Empty data returned by target.  Wrong osdata type?"));
+       {
+         if (type)
+           warning (_("Empty data returned by target.  Wrong osdata type?"));
+         else
+           warning (_("Empty type list returned by target.  No type data?"));
+       }
       else
        osdata = osdata_parse (xml);
 
@@ -294,15 +299,14 @@ info_osdata_command (char *type, int from_tty)
   int ncols;
   int nprocs;
 
-  if (type == 0)
-    /* TODO: No type could mean "list availables types".  */
-    error (_("Argument required."));
-
   osdata = get_osdata (type);
   old_chain = make_cleanup_osdata_free (osdata);
 
   nprocs = VEC_length (osdata_item_s, osdata->items);
 
+  if (!type && nprocs == 0)
+    error (_("Available types of OS data not reported."));
+
   last = VEC_last (osdata_item_s, osdata->items);
   if (last && last->columns)
     ncols = VEC_length (osdata_column_s, last->columns);