mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-24 10:35:12 +08:00
Use vector for varobj_list_children interface.
* gdb/varobj.c (varobj_list_children): Return vector of varobjs. * gdb/varobj.h (varobj_list_children): Adjust prototype. (varobj_p): Declare. Declare vector thereof. * mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust for varobj_list_children change. * Makefile.in (varobj_h): Update dependencies.
This commit is contained in:
parent
44288b4427
commit
d56d46f5c7
@ -1,3 +1,15 @@
|
|||||||
|
2008-01-30 Vladimir Prus <vladimir@codesourcery.com>
|
||||||
|
|
||||||
|
Use vector for varobj_list_children interface.
|
||||||
|
* gdb/varobj.c (varobj_list_children): Return vector
|
||||||
|
of varobjs.
|
||||||
|
* gdb/varobj.h (varobj_list_children): Adjust
|
||||||
|
prototype.
|
||||||
|
(varobj_p): Declare. Declare vector thereof.
|
||||||
|
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust
|
||||||
|
for varobj_list_children change.
|
||||||
|
* Makefile.in (varobj_h): Update dependencies.
|
||||||
|
|
||||||
2008-01-30 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
2008-01-30 Thiago Jung Bauermann <bauerman@br.ibm.com>
|
||||||
|
|
||||||
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Add support for
|
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Add support for
|
||||||
|
@ -901,7 +901,7 @@ user_regs_h = user-regs.h
|
|||||||
valprint_h = valprint.h
|
valprint_h = valprint.h
|
||||||
value_h = value.h $(doublest_h) $(frame_h) $(symtab_h) $(gdbtypes_h) \
|
value_h = value.h $(doublest_h) $(frame_h) $(symtab_h) $(gdbtypes_h) \
|
||||||
$(expression_h)
|
$(expression_h)
|
||||||
varobj_h = varobj.h $(symtab_h) $(gdbtypes_h)
|
varobj_h = varobj.h $(symtab_h) $(gdbtypes_h) $(vec_h)
|
||||||
vax_tdep_h = vax-tdep.h
|
vax_tdep_h = vax-tdep.h
|
||||||
vec_h = vec.h $(gdb_assert_h) $(gdb_string_h)
|
vec_h = vec.h $(gdb_assert_h) $(gdb_string_h)
|
||||||
version_h = version.h
|
version_h = version.h
|
||||||
|
@ -355,11 +355,12 @@ enum mi_cmd_result
|
|||||||
mi_cmd_var_list_children (char *command, char **argv, int argc)
|
mi_cmd_var_list_children (char *command, char **argv, int argc)
|
||||||
{
|
{
|
||||||
struct varobj *var;
|
struct varobj *var;
|
||||||
struct varobj **childlist;
|
VEC(varobj_p) *children;
|
||||||
struct varobj **cc;
|
struct varobj *child;
|
||||||
struct cleanup *cleanup_children;
|
struct cleanup *cleanup_children;
|
||||||
int numchild;
|
int numchild;
|
||||||
enum print_values print_values;
|
enum print_values print_values;
|
||||||
|
int ix;
|
||||||
|
|
||||||
if (argc != 1 && argc != 2)
|
if (argc != 1 && argc != 2)
|
||||||
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
|
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
|
||||||
@ -372,34 +373,28 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
|
|||||||
if (var == NULL)
|
if (var == NULL)
|
||||||
error (_("Variable object not found"));
|
error (_("Variable object not found"));
|
||||||
|
|
||||||
numchild = varobj_list_children (var, &childlist);
|
children = varobj_list_children (var);
|
||||||
ui_out_field_int (uiout, "numchild", numchild);
|
ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
print_values = mi_parse_values_option (argv[0]);
|
print_values = mi_parse_values_option (argv[0]);
|
||||||
else
|
else
|
||||||
print_values = PRINT_NO_VALUES;
|
print_values = PRINT_NO_VALUES;
|
||||||
|
|
||||||
if (numchild <= 0)
|
if (VEC_length (varobj_p, children) == 0)
|
||||||
{
|
|
||||||
xfree (childlist);
|
|
||||||
return MI_CMD_DONE;
|
return MI_CMD_DONE;
|
||||||
}
|
|
||||||
|
|
||||||
if (mi_version (uiout) == 1)
|
if (mi_version (uiout) == 1)
|
||||||
cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
|
cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
|
||||||
else
|
else
|
||||||
cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
|
cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
|
||||||
cc = childlist;
|
for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
|
||||||
while (*cc != NULL)
|
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup_child;
|
struct cleanup *cleanup_child;
|
||||||
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
|
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
|
||||||
print_varobj (*cc, print_values, 1 /* print expression */);
|
print_varobj (child, print_values, 1 /* print expression */);
|
||||||
cc++;
|
|
||||||
do_cleanups (cleanup_child);
|
do_cleanups (cleanup_child);
|
||||||
}
|
}
|
||||||
do_cleanups (cleanup_children);
|
do_cleanups (cleanup_children);
|
||||||
xfree (childlist);
|
|
||||||
return MI_CMD_DONE;
|
return MI_CMD_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
gdb/varobj.c
33
gdb/varobj.c
@ -83,10 +83,6 @@ struct varobj_root
|
|||||||
struct varobj_root *next;
|
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
|
/* Every variable in the system has a structure of this type defined
|
||||||
for it. This structure holds all information necessary to manipulate
|
for it. This structure holds all information necessary to manipulate
|
||||||
a particular object variable. Members which must be freed are noted. */
|
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;
|
/* Creates a list of the immediate children of a variable object;
|
||||||
the return code is the number of such children or -1 on error */
|
the return code is the number of such children or -1 on error */
|
||||||
|
|
||||||
int
|
VEC (varobj_p)*
|
||||||
varobj_list_children (struct varobj *var, struct varobj ***childlist)
|
varobj_list_children (struct varobj *var)
|
||||||
{
|
{
|
||||||
struct varobj *child;
|
struct varobj *child;
|
||||||
char *name;
|
char *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* sanity check: have we been passed a pointer? */
|
|
||||||
if (childlist == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*childlist = NULL;
|
|
||||||
|
|
||||||
if (var->num_children == -1)
|
if (var->num_children == -1)
|
||||||
var->num_children = number_of_children (var);
|
var->num_children = number_of_children (var);
|
||||||
|
|
||||||
/* If that failed, give up. */
|
/* If that failed, give up. */
|
||||||
if (var->num_children == -1)
|
if (var->num_children == -1)
|
||||||
return -1;
|
return var->children;
|
||||||
|
|
||||||
/* If we're called when the list of children is not yet initialized,
|
/* If we're called when the list of children is not yet initialized,
|
||||||
allocate enough elements in it. */
|
allocate enough elements in it. */
|
||||||
while (VEC_length (varobj_p, var->children) < var->num_children)
|
while (VEC_length (varobj_p, var->children) < var->num_children)
|
||||||
VEC_safe_push (varobj_p, var->children, NULL);
|
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++)
|
for (i = 0; i < var->num_children; i++)
|
||||||
{
|
{
|
||||||
varobj_p existing;
|
varobj_p existing = VEC_index (varobj_p, var->children, i);
|
||||||
|
|
||||||
/* Mark as the end in case we bail out */
|
|
||||||
*((*childlist) + i) = NULL;
|
|
||||||
|
|
||||||
existing = VEC_index (varobj_p, var->children, i);
|
|
||||||
|
|
||||||
if (existing == NULL)
|
if (existing == NULL)
|
||||||
{
|
{
|
||||||
@ -764,14 +746,9 @@ varobj_list_children (struct varobj *var, struct varobj ***childlist)
|
|||||||
existing = create_child (var, i, name);
|
existing = create_child (var, i, name);
|
||||||
VEC_replace (varobj_p, var->children, i, existing);
|
VEC_replace (varobj_p, var->children, i, existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
*((*childlist) + i) = existing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of list is marked by a NULL pointer */
|
return var->children;
|
||||||
*((*childlist) + i) = NULL;
|
|
||||||
|
|
||||||
return var->num_children;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obtain the type of an object Variable as a string similar to the one gdb
|
/* Obtain the type of an object Variable as a string similar to the one gdb
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "gdbtypes.h"
|
#include "gdbtypes.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
/* Enumeration for the format types */
|
/* Enumeration for the format types */
|
||||||
enum varobj_display_formats
|
enum varobj_display_formats
|
||||||
@ -61,6 +62,9 @@ extern char *varobj_language_string[];
|
|||||||
/* Struct thar describes a variable object instance */
|
/* Struct thar describes a variable object instance */
|
||||||
struct varobj;
|
struct varobj;
|
||||||
|
|
||||||
|
typedef struct varobj *varobj_p;
|
||||||
|
DEF_VEC_P (varobj_p);
|
||||||
|
|
||||||
/* API functions */
|
/* API functions */
|
||||||
|
|
||||||
extern struct varobj *varobj_create (char *objname,
|
extern struct varobj *varobj_create (char *objname,
|
||||||
@ -91,8 +95,9 @@ extern int varobj_get_frozen (struct varobj *var);
|
|||||||
|
|
||||||
extern int varobj_get_num_children (struct varobj *var);
|
extern int varobj_get_num_children (struct varobj *var);
|
||||||
|
|
||||||
extern int varobj_list_children (struct varobj *var,
|
/* Return the list of children of VAR. The returned vector
|
||||||
struct varobj ***childlist);
|
should not be modified in any way. */
|
||||||
|
extern VEC (varobj_p)* varobj_list_children (struct varobj *var);
|
||||||
|
|
||||||
extern char *varobj_get_type (struct varobj *var);
|
extern char *varobj_get_type (struct varobj *var);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user