From: Stan Shebs <stan@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Report available OS data types
Date: Mon, 14 Jun 2010 23:35:00 -0000 [thread overview]
Message-ID: <4C16BCB9.5040106@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 566 bytes --]
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 <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.
[-- Attachment #2: ostypes-patch-1 --]
[-- Type: text/plain, Size: 3248 bytes --]
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, "<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: 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);
next reply other threads:[~2010-06-14 23:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-14 23:35 Stan Shebs [this message]
2010-06-15 13:51 ` Daniel Jacobowitz
2010-06-15 18:40 ` Michael Snyder
2010-06-15 21:48 ` Stan Shebs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C16BCB9.5040106@codesourcery.com \
--to=stan@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox