* [RFA] Use vector for varobj_list_children interface.
@ 2008-01-17 14:56 Vladimir Prus
2008-01-29 21:54 ` Daniel Jacobowitz
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Prus @ 2008-01-17 14:56 UTC (permalink / raw)
To: gdb-patches
Presently, varobj_list_children has a varobj*** parameter
that receives the list of all children. However, at the
same time the children are stored inside varobj->children,
which is VEC(varobj_p), and varobj_list_children builds
that too. Building two data structures for the same
data does not make sense, so this patch makes varobj_list_children
return VEC(varobj_p).
OK?
- Volodya
---
gdb/mi/mi-cmd-var.c | 25 ++++++++++---------------
gdb/varobj.c | 33 +++++----------------------------
gdb/varobj.h | 7 +++++--
3 files changed, 20 insertions(+), 45 deletions(-)
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 2b5cd6d..083a34d 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -351,12 +351,13 @@ mi_print_value_p (struct type *type, enum print_values print_values)
enum mi_cmd_result
mi_cmd_var_list_children (char *command, char **argv, int argc)
{
- struct varobj *var;
- struct varobj **childlist;
- struct varobj **cc;
+ struct varobj *var;
+ VEC(varobj_p) *children;
+ struct varobj *child;
struct cleanup *cleanup_children;
int numchild;
enum print_values print_values;
+ int ix;
if (argc != 1 && argc != 2)
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
@@ -369,34 +370,28 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
if (var == NULL)
error (_("Variable object not found"));
- numchild = varobj_list_children (var, &childlist);
- ui_out_field_int (uiout, "numchild", numchild);
+ children = varobj_list_children (var);
+ ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
if (argc == 2)
print_values = mi_parse_values_option (argv[0]);
else
print_values = PRINT_NO_VALUES;
- if (numchild <= 0)
- {
- xfree (childlist);
- return MI_CMD_DONE;
- }
+ if (VEC_length (varobj_p, children) == 0)
+ return MI_CMD_DONE;
if (mi_version (uiout) == 1)
cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
else
cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
- cc = childlist;
- while (*cc != NULL)
+ for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
{
struct cleanup *cleanup_child;
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
- print_varobj (*cc, print_values, 1 /* print expression */);
- cc++;
+ print_varobj (child, print_values, 1 /* print expression */);
do_cleanups (cleanup_child);
}
do_cleanups (cleanup_children);
- xfree (childlist);
return MI_CMD_DONE;
}
diff --git a/gdb/varobj.c b/gdb/varobj.c
index d078bef..102a67e 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -83,10 +83,6 @@ struct varobj_root
struct varobj_root *next;
};
-typedef struct varobj *varobj_p;
-
-DEF_VEC_P (varobj_p);
-
/* Every variable in the system has a structure of this type defined
for it. This structure holds all information necessary to manipulate
a particular object variable. Members which must be freed are noted. */
@@ -718,42 +714,28 @@ varobj_get_num_children (struct varobj *var)
/* Creates a list of the immediate children of a variable object;
the return code is the number of such children or -1 on error */
-int
-varobj_list_children (struct varobj *var, struct varobj ***childlist)
+VEC(varobj_p)*
+varobj_list_children (struct varobj *var)
{
struct varobj *child;
char *name;
int i;
- /* sanity check: have we been passed a pointer? */
- if (childlist == NULL)
- return -1;
-
- *childlist = NULL;
-
if (var->num_children == -1)
var->num_children = number_of_children (var);
/* If that failed, give up. */
if (var->num_children == -1)
- return -1;
+ return var->children;
/* If we're called when the list of children is not yet initialized,
allocate enough elements in it. */
while (VEC_length (varobj_p, var->children) < var->num_children)
VEC_safe_push (varobj_p, var->children, NULL);
- /* List of children */
- *childlist = xmalloc ((var->num_children + 1) * sizeof (struct varobj *));
-
for (i = 0; i < var->num_children; i++)
{
- varobj_p existing;
-
- /* Mark as the end in case we bail out */
- *((*childlist) + i) = NULL;
-
- existing = VEC_index (varobj_p, var->children, i);
+ varobj_p existing = VEC_index (varobj_p, var->children, i);
if (existing == NULL)
{
@@ -764,14 +746,9 @@ varobj_list_children (struct varobj *var, struct varobj ***childlist)
existing = create_child (var, i, name);
VEC_replace (varobj_p, var->children, i, existing);
}
-
- *((*childlist) + i) = existing;
}
- /* End of list is marked by a NULL pointer */
- *((*childlist) + i) = NULL;
-
- return var->num_children;
+ return var->children;
}
/* Obtain the type of an object Variable as a string similar to the one gdb
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 588eebe..677a804 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -20,6 +20,7 @@
#include "symtab.h"
#include "gdbtypes.h"
+#include "vec.h"
/* Enumeration for the format types */
enum varobj_display_formats
@@ -61,6 +62,9 @@ extern char *varobj_language_string[];
/* Struct thar describes a variable object instance */
struct varobj;
+typedef struct varobj *varobj_p;
+DEF_VEC_P (varobj_p);
+
/* API functions */
extern struct varobj *varobj_create (char *objname,
@@ -91,8 +95,7 @@ extern int varobj_get_frozen (struct varobj *var);
extern int varobj_get_num_children (struct varobj *var);
-extern int varobj_list_children (struct varobj *var,
- struct varobj ***childlist);
+extern VEC(varobj_p)* varobj_list_children (struct varobj *var);
extern char *varobj_get_type (struct varobj *var);
--
1.5.3.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-17 14:56 [RFA] Use vector for varobj_list_children interface Vladimir Prus
@ 2008-01-29 21:54 ` Daniel Jacobowitz
2008-01-30 7:22 ` Vladimir Prus
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2008-01-29 21:54 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
On Thu, Jan 17, 2008 at 05:55:47PM +0300, Vladimir Prus wrote:
> + for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
> {
> struct cleanup *cleanup_child;
> cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
> - print_varobj (*cc, print_values, 1 /* print expression */);
> - cc++;
> + print_varobj (child, print_values, 1 /* print expression */);
> do_cleanups (cleanup_child);
> }
> do_cleanups (cleanup_children);
> - xfree (childlist);
> return MI_CMD_DONE;
> }
Not freeing children here is on purpose, right? It's now the copy
from inside the varobj.
> -int
> -varobj_list_children (struct varobj *var, struct varobj ***childlist)
> +VEC(varobj_p)*
Space there :-)
> +varobj_list_children (struct varobj *var)
> -extern int varobj_list_children (struct varobj *var,
> - struct varobj ***childlist);
> +extern VEC(varobj_p)* varobj_list_children (struct varobj *var);
Space there too.
Otherwise OK, thanks.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-29 21:54 ` Daniel Jacobowitz
@ 2008-01-30 7:22 ` Vladimir Prus
2008-01-30 8:31 ` Pierre Muller
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Prus @ 2008-01-30 7:22 UTC (permalink / raw)
To: gdb-patches
On Wednesday 30 January 2008 00:52:40 Daniel Jacobowitz wrote:
> On Thu, Jan 17, 2008 at 05:55:47PM +0300, Vladimir Prus wrote:
> > + for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
> > {
> > struct cleanup *cleanup_child;
> > cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
> > - print_varobj (*cc, print_values, 1 /* print expression */);
> > - cc++;
> > + print_varobj (child, print_values, 1 /* print expression */);
> > do_cleanups (cleanup_child);
> > }
> > do_cleanups (cleanup_children);
> > - xfree (childlist);
> > return MI_CMD_DONE;
> > }
>
> Not freeing children here is on purpose, right? It's now the copy
> from inside the varobj.
Right. I've added a comment to varobj_list_children to make
this more clear.
>
> > -int
> > -varobj_list_children (struct varobj *var, struct varobj ***childlist)
> > +VEC(varobj_p)*
>
> Space there :-)
Strictly speaking, I think that gcc does not use space after VEC. But
I have better things to do that arguing about this ;-)
> Otherwise OK, thanks.
Thanks. I've also noticed I did not update dependencies for varobj_h,
now that it includes vec.h. I've added that, and checked in.
- Volodya
^ permalink raw reply [flat|nested] 11+ messages in thread* RE: [RFA] Use vector for varobj_list_children interface.
2008-01-30 7:22 ` Vladimir Prus
@ 2008-01-30 8:31 ` Pierre Muller
2008-01-30 8:40 ` Vladimir Prus
0 siblings, 1 reply; 11+ messages in thread
From: Pierre Muller @ 2008-01-30 8:31 UTC (permalink / raw)
To: 'Vladimir Prus', gdb-patches
Volodya,
I suspect that your commit broke
gdbtk:
$ make
gcc -c -gstabs+ -O0 -I. -I../../purecvs/gdb -I../../purecvs/gdb/config
-DLOCAL
EDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
-I../../purecvs/gdb/../includ
e/opcode -I../../purecvs/gdb/../readline/.. -I../bfd
-I../../purecvs/gdb/../bfd
-I../../purecvs/gdb/../include -I../libdecnumber
-I../../purecvs/gdb/../libdecnu
mber -DMI_OUT=1 -DGDBTK -DTUI=1 -Wall -Wdeclaration-after-statement
-Wpointer
-arith -Wformat-nonliteral -Wno-unused -Wno-switch -Wno-char-subscripts
-Werror
-I../../purecvs/gdb/../libgui/src
-I/home/Pierre/gdbcvs/purecvs/itcl/itcl/gener
ic \
-I/home/Pierre/gdbcvs/purecvs/tcl/generic
-I/home/Pierre/gdbcvs/purecvs/
tk/generic -I"/home/Pierre/gdbcvs/purecvs/tk/xlib" \
../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c
../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c: In function
`variable_children':
../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c:422: error: too many
arguments to
function `varobj_list_children'
make: *** [gdbtk-varobj.o] Error 1
Could you please fix that?
Pierre Muller
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Vladimir Prus
> Sent: Wednesday, January 30, 2008 8:20 AM
> To: gdb-patches@sources.redhat.com
> Subject: Re: [RFA] Use vector for varobj_list_children interface.
>
> On Wednesday 30 January 2008 00:52:40 Daniel Jacobowitz wrote:
> > On Thu, Jan 17, 2008 at 05:55:47PM +0300, Vladimir Prus wrote:
> > > + for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
> > > {
> > > struct cleanup *cleanup_child;
> > > cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout,
> "child");
> > > - print_varobj (*cc, print_values, 1 /* print expression */);
> > > - cc++;
> > > + print_varobj (child, print_values, 1 /* print expression
> */);
> > > do_cleanups (cleanup_child);
> > > }
> > > do_cleanups (cleanup_children);
> > > - xfree (childlist);
> > > return MI_CMD_DONE;
> > > }
> >
> > Not freeing children here is on purpose, right? It's now the copy
> > from inside the varobj.
>
> Right. I've added a comment to varobj_list_children to make
> this more clear.
>
> >
> > > -int
> > > -varobj_list_children (struct varobj *var, struct varobj
> ***childlist)
> > > +VEC(varobj_p)*
> >
> > Space there :-)
>
> Strictly speaking, I think that gcc does not use space after VEC. But
> I have better things to do that arguing about this ;-)
>
> > Otherwise OK, thanks.
>
> Thanks. I've also noticed I did not update dependencies for varobj_h,
> now that it includes vec.h. I've added that, and checked in.
>
> - Volodya
^ permalink raw reply [flat|nested] 11+ messages in thread* RE: [RFA] Use vector for varobj_list_children interface.
2008-01-30 8:31 ` Pierre Muller
@ 2008-01-30 8:40 ` Vladimir Prus
2008-01-30 8:48 ` Pierre Muller
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Prus @ 2008-01-30 8:40 UTC (permalink / raw)
To: gdb-patches
Pierre Muller wrote:
> Volodya,
>
> I suspect that your commit broke
> gdbtk:
Hmm. What is gdbtk and why is it a part of gdb checkout?
> $ make
> gcc -c -gstabs+ -O0 -I. -I../../purecvs/gdb -I../../purecvs/gdb/config
> -DLOCAL
> EDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
> -I../../purecvs/gdb/../includ
> e/opcode -I../../purecvs/gdb/../readline/.. -I../bfd
> -I../../purecvs/gdb/../bfd
> -I../../purecvs/gdb/../include -I../libdecnumber
> -I../../purecvs/gdb/../libdecnu
> mber -DMI_OUT=1 -DGDBTK -DTUI=1 -Wall -Wdeclaration-after-statement
> -Wpointer
> -arith -Wformat-nonliteral -Wno-unused -Wno-switch -Wno-char-subscripts
> -Werror
> -I../../purecvs/gdb/../libgui/src
> -I/home/Pierre/gdbcvs/purecvs/itcl/itcl/gener
> ic \
> -I/home/Pierre/gdbcvs/purecvs/tcl/generic
> -I/home/Pierre/gdbcvs/purecvs/
> tk/generic -I"/home/Pierre/gdbcvs/purecvs/tk/xlib" \
> ../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c
> ../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c: In function
> `variable_children':
>
> ../../purecvs/gdb/gdbtk/generic/gdbtk-varobj.c:422: error: too many
> arguments to
> function `varobj_list_children'
> make: *** [gdbtk-varobj.o] Error 1
>
>
> Could you please fix that?
I'll look into this.
Sorry,
Volodya
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [RFA] Use vector for varobj_list_children interface.
2008-01-30 8:40 ` Vladimir Prus
@ 2008-01-30 8:48 ` Pierre Muller
2008-01-30 13:52 ` Daniel Jacobowitz
0 siblings, 1 reply; 11+ messages in thread
From: Pierre Muller @ 2008-01-30 8:48 UTC (permalink / raw)
To: 'Vladimir Prus', gdb-patches
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Vladimir Prus
> Sent: Wednesday, January 30, 2008 9:31 AM
> To: gdb-patches@sources.redhat.com
> Subject: RE: [RFA] Use vector for varobj_list_children interface.
>
> Pierre Muller wrote:
>
> > Volodya,
> >
> > I suspect that your commit broke
> > gdbtk:
>
> Hmm. What is gdbtk and why is it a part of gdb checkout?
I think it is the part used by insight
just do a cvs up -d at src/gdb level
and you will get the src/gdb/gdbtk directory if you don't have it.
To compile gdbtk,I think that you need
to configure at src level with --enable-libgui
but you might need some other directories.
Otherwise just look into gdbtk subdirectory for
the functions that you modified and adapt the code.
If you send it back to the list, I can test it and check it in
as obvious fix on your behalf.
Daniel, is that OK?
Pierre Muller
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-30 8:48 ` Pierre Muller
@ 2008-01-30 13:52 ` Daniel Jacobowitz
2008-01-30 13:57 ` Vladimir Prus
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2008-01-30 13:52 UTC (permalink / raw)
To: Pierre Muller; +Cc: 'Vladimir Prus', gdb-patches
On Wed, Jan 30, 2008 at 09:39:44AM +0100, Pierre Muller wrote:
> I think it is the part used by insight
Correct. Our position is that Insight is not part of GDB and the GDB
developers are not responsible for fixing it; it's unfortunate if it
breaks, but the Insight maintainers are generally good about fixing it
up later (Keith in particular).
> If you send it back to the list, I can test it and check it in
> as obvious fix on your behalf.
>
> Daniel, is that OK?
I'm not going to stop anyone from fixing Insight, but I don't feel
obliged to do it myself.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-30 13:52 ` Daniel Jacobowitz
@ 2008-01-30 13:57 ` Vladimir Prus
2008-01-30 14:05 ` Daniel Jacobowitz
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Prus @ 2008-01-30 13:57 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Jan 30, 2008 at 09:39:44AM +0100, Pierre Muller wrote:
>> I think it is the part used by insight
>
> Correct. Our position is that Insight is not part of GDB and the GDB
> developers are not responsible for fixing it; it's unfortunate if it
> breaks, but the Insight maintainers are generally good about fixing it
> up later (Keith in particular).
So I don't have to fix this?
- Volodya
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-30 13:57 ` Vladimir Prus
@ 2008-01-30 14:05 ` Daniel Jacobowitz
2008-01-30 14:17 ` Daniel Jacobowitz
2008-01-30 15:09 ` Vladimir Prus
0 siblings, 2 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2008-01-30 14:05 UTC (permalink / raw)
To: gdb-patches, gdb-patches
On Wed, Jan 30, 2008 at 04:51:56PM +0300, Vladimir Prus wrote:
> Daniel Jacobowitz wrote:
>
> > On Wed, Jan 30, 2008 at 09:39:44AM +0100, Pierre Muller wrote:
> >> I think it is the part used by insight
> >
> > Correct. Our position is that Insight is not part of GDB and the GDB
> > developers are not responsible for fixing it; it's unfortunate if it
> > breaks, but the Insight maintainers are generally good about fixing it
> > up later (Keith in particular).
>
> So I don't have to fix this?
Up to you. I do not personally think it is necessary.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-30 14:05 ` Daniel Jacobowitz
@ 2008-01-30 14:17 ` Daniel Jacobowitz
2008-01-30 15:09 ` Vladimir Prus
1 sibling, 0 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2008-01-30 14:17 UTC (permalink / raw)
To: gdb-patches, gdb-patches
On Wed, Jan 30, 2008 at 04:51:56PM +0300, Vladimir Prus wrote:
> Daniel Jacobowitz wrote:
>
> > On Wed, Jan 30, 2008 at 09:39:44AM +0100, Pierre Muller wrote:
> >> I think it is the part used by insight
> >
> > Correct. Our position is that Insight is not part of GDB and the GDB
> > developers are not responsible for fixing it; it's unfortunate if it
> > breaks, but the Insight maintainers are generally good about fixing it
> > up later (Keith in particular).
>
> So I don't have to fix this?
Up to you. I do not personally think it is necessary.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] Use vector for varobj_list_children interface.
2008-01-30 14:05 ` Daniel Jacobowitz
2008-01-30 14:17 ` Daniel Jacobowitz
@ 2008-01-30 15:09 ` Vladimir Prus
1 sibling, 0 replies; 11+ messages in thread
From: Vladimir Prus @ 2008-01-30 15:09 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Jan 30, 2008 at 04:51:56PM +0300, Vladimir Prus wrote:
>> Daniel Jacobowitz wrote:
>>
>> > On Wed, Jan 30, 2008 at 09:39:44AM +0100, Pierre Muller wrote:
>> >> I think it is the part used by insight
>> >
>> > Correct. Our position is that Insight is not part of GDB and the GDB
>> > developers are not responsible for fixing it; it's unfortunate if it
>> > breaks, but the Insight maintainers are generally good about fixing it
>> > up later (Keith in particular).
>>
>> So I don't have to fix this?
>
> Up to you. I do not personally think it is necessary.
Ok. I'll then leave this matter to Insight maintainers.
- Volodya
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-01-30 14:17 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-17 14:56 [RFA] Use vector for varobj_list_children interface Vladimir Prus
2008-01-29 21:54 ` Daniel Jacobowitz
2008-01-30 7:22 ` Vladimir Prus
2008-01-30 8:31 ` Pierre Muller
2008-01-30 8:40 ` Vladimir Prus
2008-01-30 8:48 ` Pierre Muller
2008-01-30 13:52 ` Daniel Jacobowitz
2008-01-30 13:57 ` Vladimir Prus
2008-01-30 14:05 ` Daniel Jacobowitz
2008-01-30 14:17 ` Daniel Jacobowitz
2008-01-30 15:09 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox