From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9954 invoked by alias); 14 Jun 2010 23:35:33 -0000 Received: (qmail 9944 invoked by uid 22791); 14 Jun 2010 23:35:33 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 23:35:28 +0000 Received: (qmail 15690 invoked from network); 14 Jun 2010 23:35:26 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 14 Jun 2010 23:35:26 -0000 Message-ID: <4C16BCB9.5040106@codesourcery.com> Date: Mon, 14 Jun 2010 23:35:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Report available OS data types Content-Type: multipart/mixed; boundary="------------070802080903080805040405" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00330.txt.bz2 This is a multi-part message in MIME format. --------------070802080903080805040405 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 566 As a lead-in to some upcoming work on "OS awareness" for Linux GDB, here is a little patch for "info os" to return the types of data available (which is currently just "processes"), instead of erroring out. Stan 2010-06-14 Stan Shebs * 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. --------------070802080903080805040405 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="ostypes-patch-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ostypes-patch-1" Content-length: 3248 Index: linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/linux-nat.c,v retrieving revision 1.170 diff -p -r1.170 linux-nat.c *** linux-nat.c 28 May 2010 18:23:15 -0000 1.170 --- linux-nat.c 14 Jun 2010 22:09:34 -0000 *************** linux_nat_xfer_osdata (struct target_ops *** 4948,4953 **** --- 4948,4992 ---- 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, "\n"); + + obstack_xml_printf ( + &obstack, + "" + "processes" + "Listing of all processes" + ""); + + obstack_grow_str0 (&obstack, "\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: osdata.c =================================================================== RCS file: /cvs/src/src/gdb/osdata.c,v retrieving revision 1.6 diff -p -r1.6 osdata.c *** osdata.c 16 May 2010 00:46:46 -0000 1.6 --- osdata.c 14 Jun 2010 22:09:34 -0000 *************** get_osdata (const char *type) *** 256,262 **** struct cleanup *old_chain = make_cleanup (xfree, xml); if (xml[0] == '\0') ! warning (_("Empty data returned by target. Wrong osdata type?")); else osdata = osdata_parse (xml); --- 256,267 ---- struct cleanup *old_chain = make_cleanup (xfree, xml); if (xml[0] == '\0') ! { ! 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); *************** info_osdata_command (char *type, int fro *** 294,308 **** 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); last = VEC_last (osdata_item_s, osdata->items); if (last && last->columns) ncols = VEC_length (osdata_column_s, last->columns); --- 299,312 ---- int ncols; int nprocs; 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); --------------070802080903080805040405--