* [PATCH] Report available OS data types
@ 2010-06-14 23:35 Stan Shebs
2010-06-15 13:51 ` Daniel Jacobowitz
2010-06-15 18:40 ` Michael Snyder
0 siblings, 2 replies; 4+ messages in thread
From: Stan Shebs @ 2010-06-14 23:35 UTC (permalink / raw)
To: gdb-patches
[-- 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);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Report available OS data types
2010-06-14 23:35 [PATCH] Report available OS data types Stan Shebs
@ 2010-06-15 13:51 ` Daniel Jacobowitz
2010-06-15 18:40 ` Michael Snyder
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2010-06-15 13:51 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches
On Mon, Jun 14, 2010 at 04:35:21PM -0700, Stan Shebs wrote:
> 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.
Doesn't something in this patch need a doc update?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Report available OS data types
2010-06-14 23:35 [PATCH] Report available OS data types Stan Shebs
2010-06-15 13:51 ` Daniel Jacobowitz
@ 2010-06-15 18:40 ` Michael Snyder
2010-06-15 21:48 ` Stan Shebs
1 sibling, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2010-06-15 18:40 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches
Stan Shebs wrote:
> 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.
Is this checked in? I still see:
(gdb) info os
Argument required.
Am I misunderstanding something? How do you get it to list
the types available?
> 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.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Report available OS data types
2010-06-15 18:40 ` Michael Snyder
@ 2010-06-15 21:48 ` Stan Shebs
0 siblings, 0 replies; 4+ messages in thread
From: Stan Shebs @ 2010-06-15 21:48 UTC (permalink / raw)
To: Michael Snyder; +Cc: Stan Shebs, gdb-patches
Michael Snyder wrote:
> Stan Shebs wrote:
>> 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.
>
> Is this checked in? I still see:
>
> (gdb) info os
> Argument required.
>
> Am I misunderstanding something? How do you get it to list
> the types available?
Not committed yet, I was giving people a chance to comment. Apparently
it would be good to document the new behavior. :-)
Stan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-15 21:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14 23:35 [PATCH] Report available OS data types Stan Shebs
2010-06-15 13:51 ` Daniel Jacobowitz
2010-06-15 18:40 ` Michael Snyder
2010-06-15 21:48 ` Stan Shebs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox