/* Implementation of the GDB variable objects API.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
not NULL. */
struct frame_id frame;
- /* The thread ID that this varobj_root belong to. This field
+ /* The global thread ID that this varobj_root belongs to. This field
is only valid if valid_block is not NULL.
When not 0, indicates which thread 'frame' belongs to.
When 0, indicates that the thread list was empty when the varobj_root
varobj_item *saved_item;
};
-struct cpstack
-{
- char *name;
- struct cpstack *next;
-};
-
/* A list of varobjs */
struct vlist
/* Helper functions for the above subcommands. */
-static int delete_variable (struct cpstack **, struct varobj *, int);
+static int delete_variable (struct varobj *, int);
-static void delete_variable_1 (struct cpstack **, int *,
- struct varobj *, int, int);
+static void delete_variable_1 (int *, struct varobj *, int, int);
static int install_variable (struct varobj *);
static enum varobj_display_formats variable_default_display (struct varobj *);
-static void cppush (struct cpstack **pstack, char *name);
-
-static char *cppop (struct cpstack **pstack);
-
static int update_type_if_necessary (struct varobj *var,
struct value *new_value);
static struct varobj_root *rootlist;
/* Prime number indicating the number of buckets in the hash table. */
-/* A prime large enough to avoid too many colisions. */
+/* A prime large enough to avoid too many collisions. */
#define VAROBJ_TABLE_SIZE 227
/* Pointer to the varobj hash table (built at run time). */
}
#endif
-/* Creates a varobj (not its children). */
-
/* Return the full FRAME which corresponds to the given CORE_ADDR
or NULL if no FRAME on the chain corresponds to CORE_ADDR. */
return NULL;
}
+/* Creates a varobj (not its children). */
+
struct varobj *
varobj_create (char *objname,
char *expression, CORE_ADDR frame, enum varobj_type type)
error (_("Failed to find the specified frame"));
var->root->frame = get_frame_id (fi);
- var->root->thread_id = pid_to_thread_id (inferior_ptid);
+ var->root->thread_id = ptid_to_global_thread_id (inferior_ptid);
old_id = get_frame_id (get_selected_frame (NULL));
select_frame (fi);
}
return name_of_variable (var);
}
-/* Deletes a varobj and all its children if only_children == 0,
- otherwise deletes only the children. If DELLIST is non-NULL, it is
- assigned a malloc'ed list of all the (malloc'ed) names of the variables
- that have been deleted (NULL terminated). Returns the number of deleted
- variables. */
+/* See varobj.h. */
int
-varobj_delete (struct varobj *var, char ***dellist, int only_children)
+varobj_delete (struct varobj *var, int only_children)
{
- int delcount;
- int mycount;
- struct cpstack *result = NULL;
- char **cp;
-
- /* Initialize a stack for temporary results. */
- cppush (&result, NULL);
-
- if (only_children)
- /* Delete only the variable children. */
- delcount = delete_variable (&result, var, 1 /* only the children */ );
- else
- /* Delete the variable and all its children. */
- delcount = delete_variable (&result, var, 0 /* parent+children */ );
-
- /* We may have been asked to return a list of what has been deleted. */
- if (dellist != NULL)
- {
- *dellist = XNEWVEC (char *, delcount + 1);
-
- cp = *dellist;
- mycount = delcount;
- *cp = cppop (&result);
- while ((*cp != NULL) && (mycount > 0))
- {
- mycount--;
- cp++;
- *cp = cppop (&result);
- }
-
- if (mycount || (*cp != NULL))
- warning (_("varobj_delete: assertion failed - mycount(=%d) <> 0"),
- mycount);
- }
-
- return delcount;
+ return delete_variable (var, only_children);
}
#if HAVE_PYTHON
*cchanged = 1;
for (j = i; j < VEC_length (varobj_p, var->children); ++j)
- varobj_delete (VEC_index (varobj_p, var->children, j), NULL, 0);
+ varobj_delete (VEC_index (varobj_p, var->children, j), 0);
VEC_truncate (varobj_p, var->children, i);
}
var->type = new_type;
/* This information may be not valid for a new type. */
- varobj_delete (var, NULL, 1);
+ varobj_delete (var, 1);
VEC_free (varobj_p, var->children);
var->num_children = -1;
return 1;
Py_XDECREF (constructor);
/* If there are any children now, wipe them. */
- varobj_delete (var, NULL, 1 /* children only */);
+ varobj_delete (var, 1 /* children only */);
var->num_children = -1;
do_cleanups (back_to);
{
/* The children are no longer valid; delete them now.
Report the fact that its type changed as well. */
- varobj_delete (v, NULL, 1 /* only_children */);
+ varobj_delete (v, 1 /* only_children */);
v->num_children = -1;
v->to = -1;
v->from = -1;
*/
static int
-delete_variable (struct cpstack **resultp, struct varobj *var,
- int only_children_p)
+delete_variable (struct varobj *var, int only_children_p)
{
int delcount = 0;
- delete_variable_1 (resultp, &delcount, var,
- only_children_p, 1 /* remove_from_parent_p */ );
+ delete_variable_1 (&delcount, var, only_children_p,
+ 1 /* remove_from_parent_p */ );
return delcount;
}
and the parent is not removed we dump core. It must be always
initially called with remove_from_parent_p set. */
static void
-delete_variable_1 (struct cpstack **resultp, int *delcountp,
- struct varobj *var, int only_children_p,
+delete_variable_1 (int *delcountp, struct varobj *var, int only_children_p,
int remove_from_parent_p)
{
int i;
continue;
if (!remove_from_parent_p)
child->parent = NULL;
- delete_variable_1 (resultp, delcountp, child, 0, only_children_p);
+ delete_variable_1 (delcountp, child, 0, only_children_p);
}
VEC_free (varobj_p, var->children);
yet been installed, don't report it, it belongs to the caller... */
if (var->obj_name != NULL)
{
- cppush (resultp, xstrdup (var->obj_name));
*delcountp = *delcountp + 1;
}
return FORMAT_NATURAL;
}
-/* FIXME: The following should be generic for any pointer. */
-static void
-cppush (struct cpstack **pstack, char *name)
-{
- struct cpstack *s;
-
- s = XNEW (struct cpstack);
- s->name = name;
- s->next = *pstack;
- *pstack = s;
-}
-
-/* FIXME: The following should be generic for any pointer. */
-static char *
-cppop (struct cpstack **pstack)
-{
- struct cpstack *s;
- char *v;
-
- if ((*pstack)->name == NULL && (*pstack)->next == NULL)
- return NULL;
-
- s = *pstack;
- v = s->name;
- *pstack = (*pstack)->next;
- xfree (s);
-
- return v;
-}
-\f
/*
* Language-dependencies
*/
}
else
{
- ptid_t ptid = thread_id_to_pid (var->root->thread_id);
- if (in_thread_list (ptid))
+ ptid_t ptid = global_thread_id_to_ptid (var->root->thread_id);
+
+ if (!ptid_equal (minus_one_ptid, ptid))
{
switch_to_thread (ptid);
within_scope = check_scope (var);
var->root->exp = tmp_var->root->exp;
tmp_var->root->exp = tmp_exp;
- varobj_delete (tmp_var, NULL, 0);
+ varobj_delete (tmp_var, 0);
*type_changed = 0;
}
else
tmp_var->obj_name = xstrdup (var->obj_name);
tmp_var->from = var->from;
tmp_var->to = var->to;
- varobj_delete (var, NULL, 0);
+ varobj_delete (var, 0);
install_variable (tmp_var);
*var_handle = tmp_var;
/* The type has mutated, so the children are no longer valid.
Just delete them, and tell our caller that the type has
changed. */
- varobj_delete (var, NULL, 1 /* only_children */);
+ varobj_delete (var, 1 /* only_children */);
var->num_children = -1;
var->to = -1;
var->from = -1;
struct type *type = NULL;
long len = 0;
char *encoding = NULL;
- struct gdbarch *gdbarch = NULL;
/* Initialize it just to avoid a GCC false warning. */
CORE_ADDR str_addr = 0;
int string_print = 0;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
- gdbarch = get_type_arch (value_type (value));
#if HAVE_PYTHON
if (gdb_python_initialized)
{
if (s)
{
+ struct gdbarch *gdbarch;
char *hint;
hint = gdbpy_get_display_hint (value_formatter);
len = strlen (s);
thevalue = (char *) xmemdup (s, len + 1, len + 1);
+ gdbarch = get_type_arch (value_type (value));
type = builtin_type (gdbarch)->builtin_char;
xfree (s);
if (tmp_var != NULL)
{
tmp_var->obj_name = xstrdup (var->obj_name);
- varobj_delete (var, NULL, 0);
+ varobj_delete (var, 0);
install_variable (tmp_var);
}
else