System notice: In light of the Debian OpenSSL security issue we've regenerated the server keys. See this thread for instructions and the new key fingerprints.

Commit 10aa0fe9d492aa3d3cab109a29f020ab449e2340

Rename value-related functions to fit pattern.

Commit diff

gdb/python/python-internal.h

 
3131extern PyTypeObject value_object_type;
3232extern PyTypeObject symbol_object_type;
3333
34PyObject *gdb_value_from_int (PyObject *self, PyObject *args);
35PyObject *gdb_value_from_history (PyObject *self, PyObject *args);
34PyObject *gdbpy_make_value_from_int (PyObject *self, PyObject *args);
35PyObject *gdbpy_get_value_from_history (PyObject *self, PyObject *args);
3636PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
3737PyObject *gdbpy_get_frames (PyObject *, PyObject *);
3838PyObject *gdbpy_get_current_frame (PyObject *, PyObject *);
4040PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args);
4141PyObject *gdbpy_get_selected_frame (PyObject *self, PyObject *args);
4242
43PyObject *value_from_value (struct value *v);
4443PyObject *variable_to_python (struct cmd_list_element *);
4544PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
4645PyObject *symtab_to_symtab_object (struct symtab *symtab);
4746PyObject *symbol_to_symbol_object (struct symbol *sym);
4847PyObject *block_to_block_object (struct block *block);
4948PyObject *value_to_value_object (struct value *v);
49PyObject *gdb_owned_value_to_value_object (struct value *v);
5050
5151struct block *block_object_to_block (PyObject *obj);
5252struct symbol *symbol_object_to_symbol (PyObject *obj);
toggle raw diff

gdb/python/python.c

 
6060 if (!initialized)
6161 {
6262 static PyMethodDef GdbMethods[] = {
63 {"value_from_int", gdb_value_from_int, METH_VARARGS,
64 "Get a value from int"},
65 {"value_from_history", gdb_value_from_history, METH_VARARGS,
66 "Get a value from history"},
63 { "make_value_from_int", gdbpy_make_value_from_int, METH_VARARGS,
64 "Make a value from int" },
65 { "get_value_from_history", gdbpy_get_value_from_history, METH_VARARGS,
66 "Get a value from history" },
6767 { "execute", execute_gdb_command, METH_VARARGS,
6868 "Execute a gdb command" },
6969 { "show", get_show_variable, METH_VARARGS,
150150 }
151151
152152 tuple = PyTuple_New (1);
153 PyTuple_SetItem (tuple, 0, value_from_value (value));
153 PyTuple_SetItem (tuple, 0, gdb_owned_value_to_value_object (value));
154154
155155 result = PyObject_Call (format, tuple, Py_None);
156156 if (result && PyString_Check (result))
194194 }
195195
196196 tuple = PyTuple_New (1);
197 PyTuple_SetItem (tuple, 0, value_from_value (varobj_get_raw_value (var)));
197 PyTuple_SetItem (tuple, 0, gdb_owned_value_to_value_object (varobj_get_raw_value (var)));
198198
199199 result = PyObject_Call (format, tuple, Py_None);
200200 if (!result)
toggle raw diff

gdb/python/value.c

 
3535
3636static void valpy_dealloc (PyObject *obj);
3737static PyObject *valpy_dereference (PyObject *self, PyObject *args);
38static PyObject *valpy_element (PyObject *self, PyObject *args);
38static PyObject *valpy_get_element (PyObject *self, PyObject *args);
3939static PyObject *valpy_str (PyObject *self);
4040static PyObject *valpy_increment (PyObject *self, PyObject *args);
4141static PyObject *valpy_equal_p (PyObject *self, PyObject *args);
4545
4646static PyMethodDef value_object_methods[] = {
4747 { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
48 { "element", valpy_element, METH_VARARGS, "Obtains element inside value." },
48 { "get_element", valpy_get_element, METH_VARARGS,
49 "Obtains element inside value." },
4950 { "increment", valpy_increment, METH_VARARGS,
5051 "Increment value by the given amount." },
5152 { "equals", valpy_equal_p, METH_VARARGS, "Compare values." },
134134
135135/* Takes value and string name of element inside that value. */
136136static PyObject *
137valpy_element (PyObject *self, PyObject *args)
137valpy_get_element (PyObject *self, PyObject *args)
138138{
139139 value_object *self_value = (value_object *) self;
140140 char *field;
301301 return PyInt_FromLong (ret);
302302}
303303
304/* FIXME: clarify the naming to say the value
305 won't be deleted by the Python code. */
304/* A value owned by GDB is in the all_values chain, so it will be freed
305 automatically when not needed anymore (i.e., before the current command
306 completes). */
306307PyObject *
307value_from_value (struct value *v)
308gdb_owned_value_to_value_object (struct value *v)
308309{
309310 value_object *result = PyObject_New (value_object, &value_object_type);
310311 if (result != NULL)
313313 result->value = v;
314314 result->owned_by_gdb = 1;
315315 /* FIXME: should we do it? What is it? */
316 /* I don't think it is needed, since a GDB owned value has a very short
317 lifetime. The purpose of the list is explained in the comment above
318 its declaration. -- bauermann */
316319 value_prepend_to_list (&values_in_python, v);
317320 }
318321 return (PyObject *)result;
319322}
320323
324/* Returns an object for a value which is released from the all_values chain,
325 so its lifetime is not bound to the execution of a command. */
321326PyObject *
322327value_to_value_object (struct value *v)
323328{
331331 VALPY_RETURN_VALUE (val_obj, v);
332332}
333333
334struct value *
335value_object_to_value (PyObject *self)
336{
337 value_object *real = (value_object *)self;
338 return real->value;
339}
340
334341PyObject *
335gdb_value_from_int (PyObject *self, PyObject *args)
342gdbpy_make_value_from_int (PyObject *self, PyObject *args)
336343{
337344 int i;
338345 struct value *res_val = NULL; /* Initialize to appease gcc warning. */
359359}
360360
361361PyObject *
362gdb_value_from_history (PyObject *self, PyObject *args)
362gdbpy_get_value_from_history (PyObject *self, PyObject *args)
363363{
364364 int i;
365365 struct value *res_val = NULL; /* Initialize to appease gcc warning. */
390390
391391 values_in_python = NULL;
392392}
393
394struct value *
395value_object_to_value (PyObject *self)
396{
397 value_object *real = (value_object *)self;
398 return real->value;
399}
toggle raw diff

gdb/varobj.c

 
857857 tuple = PyTuple_New (1);
858858 back_to = make_cleanup_py_decref (tuple);
859859 /* Steals the reference. */
860 PyTuple_SetItem (tuple, 0, value_from_value (var->value));
860 PyTuple_SetItem (tuple, 0, gdb_owned_value_to_value_object (var->value));
861861 children = PyObject_Call (var->children_lister, tuple, Py_None);
862862 make_cleanup_py_decref (children);
863863
21072107 PyObject *py_s;
21082108 char *s;
21092109
2110 py_value = value_from_value (value);
2110 py_value = gdb_owned_value_to_value_object (value);
21112111 tuple = PyTuple_New (1);
21122112 back_to = make_cleanup_py_decref (tuple);
21132113 /* Steals the reference. */
toggle raw diff