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 c6466d7c1dbfbcee2dc7508e7421de9a91d3020f

Fix compilation using --without-python.

Commit diff

gdb/cli/cli-script.c

 
3333#include "cli/cli-decode.h"
3434#include "cli/cli-script.h"
3535#include "gdb_assert.h"
36
37#ifdef HAVE_PYTHON
3638#include "python/python.h"
39#endif
3740
3841/* Prototypes for local functions */
3942
229229 continue;
230230 }
231231
232#ifdef HAVE_PYTHON
232233 if (list->control_type == python_control)
233234 {
234235 ui_out_field_string (uiout, NULL, "python");
241241 list = list->next;
242242 continue;
243243 }
244#endif
244245
245246 /* ignore illegal command type and try next */
246247 list = list->next;
546546 break;
547547 }
548548 case python_control:
549#ifdef HAVE_PYTHON
549550 {
550551 eval_python_from_control_command (cmd);
551552 ret = simple_control;
552553 break;
553554 }
555#else
556 warning (_("Python scripting is not supported in this copy of GDB."));
557 break;
558#endif
554559
555560 default:
556561 warning (_("Invalid control type in canned commands structure."));
925925 first_arg++;
926926 *command = build_command_line (commands_control, first_arg);
927927 }
928#ifdef HAVE_PYTHON
928929 else if (p1 - p == 6 && !strncmp (p, "python", 6))
929930 {
930931 /* Note that we ignore the inline "python command" form
931932 here. */
932933 *command = build_command_line (python_control, "");
933934 }
935#endif
934936 else if (p1 - p == 10 && !strncmp (p, "loop_break", 10))
935937 {
936938 *command = (struct command_line *)
10131013 {
10141014 if (current_cmd->control_type == while_control
10151015 || current_cmd->control_type == if_control
1016 || current_cmd->control_type == commands_control
1017 || current_cmd->control_type == python_control)
1016#ifdef HAVE_PYTHON
1017 || current_cmd->control_type == python_control
1018#endif
1019 || current_cmd->control_type == commands_control)
10181020 {
10191021 /* Success reading an entire canned sequence of commands. */
10201022 ret = simple_control;
10671067 on it. */
10681068 if (next->control_type == while_control
10691069 || next->control_type == if_control
1070 || next->control_type == commands_control
1071 || next->control_type == python_control)
1070#ifdef HAVE_PYTHON
1071 || next->control_type == python_control
1072#endif
1073 || next->control_type == commands_control)
10721074 {
10731075 control_level++;
10741076 ret = recurse_read_control_structure (next);
11431143
11441144 if (next->control_type == while_control
11451145 || next->control_type == if_control
1146 || next->control_type == commands_control
1147 || next->control_type == python_control)
1146#ifdef HAVE_PYTHON
1147 || next->control_type == python_control
1148#endif
1149 || next->control_type == commands_control)
11481150 {
11491151 control_level++;
11501152 ret = recurse_read_control_structure (next);
toggle raw diff

gdb/eval.c

 
539539 return value_of_internalvar (exp->elts[pc + 1].internalvar);
540540
541541 case OP_INTERNALFUNC:
542#ifdef HAVE_PYTHON
542543 tem = longest_to_int (exp->elts[pc + 1].longconst);
543544 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
544545 /* FIXME: handling noside == EVAL_AVOID_SIDE_EFFECTS? */
545546 if (noside == EVAL_SKIP)
546547 goto nosideret;
547548 return value_of_python (&exp->elts[pc + 2].string, tem);
549#else
550 error (_("Python scripting is not supported in this copy of GDB."));
551#endif
548552
549553 case OP_STRING:
550554 tem = longest_to_int (exp->elts[pc + 1].longconst);
toggle raw diff

gdb/mi/mi-cmd-var.c

 
237237 return MI_CMD_DONE;
238238}
239239
240#ifdef HAVE_PYTHON
240241enum mi_cmd_result
241242mi_cmd_var_set_type_visualizer (char *command, char **argv, int argc)
242243{
278278
279279 return MI_CMD_DONE;
280280}
281#endif /* HAVE_PYTHON */
281282
282283
283284enum mi_cmd_result
toggle raw diff

gdb/mi/mi-cmds.c

 
161161 { "var-list-children", { NULL, 0 }, 0, mi_cmd_var_list_children},
162162 { "var-set-format", { NULL, 0 }, 0, mi_cmd_var_set_format},
163163 { "var-set-frozen", { NULL, 0 }, 0, mi_cmd_var_set_frozen},
164#ifdef HAVE_PYTHON
164165 { "var-set-type-visualizer", { NULL, 0 }, 0, mi_cmd_var_set_type_visualizer},
165166 { "var-clear-type-visualizers", { NULL, 0 }, 0,
166167 mi_cmd_var_clear_type_visualizers},
167168 { "var-set-visualizer", { NULL, 0 }, 0, mi_cmd_var_set_visualizer},
169#endif
168170 { "var-show-attributes", { NULL, 0 }, 0, mi_cmd_var_show_attributes},
169171 { "var-show-format", { NULL, 0 }, 0, mi_cmd_var_show_format},
170172 { "var-update", { NULL, 0 }, 0, mi_cmd_var_update},
toggle raw diff

gdb/mi/mi-cmds.h

 
118118extern mi_cmd_argv_ftype mi_cmd_var_list_children;
119119extern mi_cmd_argv_ftype mi_cmd_var_set_format;
120120extern mi_cmd_argv_ftype mi_cmd_var_set_frozen;
121#ifdef HAVE_PYTHON
121122extern mi_cmd_argv_ftype mi_cmd_var_set_type_visualizer;
122123extern mi_cmd_argv_ftype mi_cmd_var_clear_type_visualizers;
123124extern mi_cmd_argv_ftype mi_cmd_var_set_visualizer;
125#endif
124126extern mi_cmd_argv_ftype mi_cmd_var_show_attributes;
125127extern mi_cmd_argv_ftype mi_cmd_var_show_format;
126128extern mi_cmd_argv_ftype mi_cmd_var_update;
toggle raw diff

gdb/value.c

 
3535#include "regcache.h"
3636#include "block.h"
3737#include "dfp.h"
38
39#ifdef HAVE_PYTHON
3840#include "python/python.h"
41#endif
3942
4043/* Prototypes for exported functions. */
4144
959959 for (var = internalvars; var; var = var->next)
960960 preserve_one_value (var->value, objfile, copied_types);
961961
962#ifdef HAVE_PYTHON
962963 for (val = values_in_python; val; val = val->next)
963964 preserve_one_value (val, objfile, copied_types);
965#endif
964966
965967 htab_delete (copied_types);
966968}
toggle raw diff

gdb/varobj.c

 
3333#include "varobj.h"
3434#include "vec.h"
3535
36#ifdef HAVE_PYTHON
3637#include "python/python.h"
3738#include "python/python-internal.h"
39#endif
3840
3941/* Non-zero if we want to see trace of varobj level stuff. */
4042
132132 /* Children of this object. */
133133 VEC (varobj_p) *children;
134134
135#ifdef HAVE_PYTHON
135136 /* Whether the children of this varobj were requested. This field is
136137 used to decide if dynamic varobj should recompute their children.
137138 In the event that the frontend never asked for the children, we
138139 can avoid that. */
139140 int children_requested;
141#endif
140142
141143 /* Description of the root variable. Points to root variable for children. */
142144 struct varobj_root *root;
162162 frozen. */
163163 int not_fetched;
164164
165#ifdef HAVE_PYTHON
165166 /* A Python object used to visualize this variable object.
166167 FIXME: free this in dtor.
167168 */
168169 PyObject *value_formatter;
169170 PyObject *children_lister;
171#endif
170172};
171173
172174struct cpstack
185185 struct vlist *next;
186186};
187187
188#ifdef HAVE_PYTHON
188189typedef struct type_visualizer
189190{
190191 char *type_regexp;
193193} type_visualizer;
194194
195195DEF_VEC_O (type_visualizer);
196#endif
196197
197198/* Private function prototypes */
198199
239239static int install_new_value (struct varobj *var, struct value *value,
240240 int initial);
241241
242#ifdef HAVE_PYTHON
242243static void install_default_visualizer (struct varobj *var);
244#endif
243245
244246static struct value *
245247value_struct_element_by_name (struct value *value, const char *name);
263263static char *my_value_of_variable (struct varobj *var);
264264
265265static char *value_get_print_value (struct value *value,
266 enum varobj_display_formats format,
267 PyObject *value_formatter);
266 enum varobj_display_formats format
267#ifdef HAVE_PYTHON
268 , PyObject *value_formatter
269#endif
270 );
268271
269272static int varobj_value_is_changeable_p (struct varobj *var);
270273
436436/* Pointer to the varobj hash table (built at run time) */
437437static struct vlist **varobj_table;
438438
439#ifdef HAVE_PYTHON
439440static VEC (type_visualizer) *type_visualizers = NULL;
441#endif
440442
441443/* Is the variable X one of our "fake" children? */
442444#define CPLUS_FAKE_CHILD(x) \
599599 }
600600
601601 discard_cleanups (old_chain);
602#ifdef HAVE_PYTHON
602603 install_default_visualizer (var);
604#endif
603605 return var;
604606}
605607
731731 && var->value && !value_lazy (var->value))
732732 {
733733 free (var->print_value);
734 var->print_value = value_get_print_value (var->value, var->format,
735 var->value_formatter);
734 var->print_value = value_get_print_value (var->value, var->format
735#ifdef HAVE_PYTHON
736 , var->value_formatter
737#endif
738 );
736739 }
737740
738741 return var->format;
739742}
740743
744#ifdef HAVE_PYTHON
741745void
742746varobj_set_visualizer (struct varobj *var, const char *visualizer)
743747{
823823{
824824 VEC_free (type_visualizer, type_visualizers);
825825}
826#endif /* HAVE_PYTHON */
826827
827828enum varobj_display_formats
828829varobj_get_display_format (struct varobj *var)
860860 return var->num_children;
861861}
862862
863#ifdef HAVE_PYTHON
863864static
864865int update_dynamic_varobj_children (struct varobj *var,
865866 VEC (varobj_p) **changed,
951951
952952 return children_changed;
953953}
954#endif /* HAVE_PYTHON */
954955
955956/* Creates a list of the immediate children of a variable object;
956957 the return code is the number of such children or -1 on error */
963963 char *name;
964964 int i;
965965
966#ifdef HAVE_PYTHON
966967 var->children_requested = 1;
967968
968969 if (var->children_lister)
974974 update_dynamic_varobj_children (var, NULL, NULL);
975975 return var->children;
976976 }
977#endif
977978
978979 if (var->num_children == -1)
979980 var->num_children = number_of_children (var);
10001000 name = name_of_child (var, i);
10011001 existing = create_child (var, i, name);
10021002 VEC_replace (varobj_p, var->children, i, existing);
1003#ifdef HAVE_PYTHON
10031004 install_default_visualizer (existing);
1005#endif
10041006 }
10051007 }
10061008
10071009 return var->children;
10081010}
10091011
1012#ifdef HAVE_PYTHON
10101013struct varobj *
10111014varobj_add_child (struct varobj *var, const char *name, struct value *value)
10121015{
10201020 install_default_visualizer (v);
10211021 return v;
10221022}
1023#endif
10231024
10241025/* Obtain the type of an object Variable as a string similar to the one gdb
10251026 prints on the console */
12221222 gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
12231223 changeable = varobj_value_is_changeable_p (var);
12241224
1225#ifdef HAVE_PYTHON
12251226 /* If the type has custom visualizer, we consider it to be always
12261227 changeable. FIXME: need to make sure this behaviour will not
12271228 mess up read-sensitive values. */
12281229 if (var->value_formatter || var->children_lister)
12291230 changeable = 1;
1231#endif
12301232
12311233 need_to_fetch = changeable;
12321234
12871287 should not be fetched. */
12881288 if (value && !value_lazy (value))
12891289 {
1290 print_value = value_get_print_value (value, var->format,
1291 var->value_formatter);
1290 print_value = value_get_print_value (value, var->format
1291#ifdef HAVE_PYTHON
1292 , var->value_formatter
1293#endif
1294 );
12921295 }
12931296
12941297 /* If the type is changeable, compare the old and the new values.
13571357 return changed;
13581358}
13591359
1360#ifdef HAVE_PYTHON
13601361void install_default_visualizer (struct varobj *var)
13611362{
13621363 char *type = varobj_get_type (var);
13771377 xfree (type);
13781378 }
13791379}
1380#endif
13801381
13811382/* Update the values for a variable and its children. This is a
13821383 two-pronged attack. First, re-parse the value for the root's
14561456 r.status = VAROBJ_NOT_IN_SCOPE;
14571457 r.value_installed = 1;
14581458
1459#ifdef HAVE_PYTHON
14591460 if (r.type_changed)
14601461 install_default_visualizer (*varp);
1462#endif
14611463
14621464 if (r.status == VAROBJ_NOT_IN_SCOPE)
14631465 {
14951495 }
14961496 }
14971497
1498#ifdef HAVE_PYTHON
14981499 /* We probably should not get children of a varobj that has
14991500 children_lister, but for which -var-list-children was never
15001501 invoked. Presumably, such varobj is not yet expanded in the
15311531 VEC_safe_push (varobj_update_result, result, &r);
15321532 continue;
15331533 }
1534#endif /* HAVE_PYTHON */
15341535
15351536 /* Push any children. Use reverse order so that the first
15361537 child is popped from the work stack first, and so
18171817 var->print_value = NULL;
18181818 var->frozen = 0;
18191819 var->not_fetched = 0;
1820#ifdef HAVE_PYTHON
18201821 var->value_formatter = NULL;
18211822 var->children_lister = NULL;
18221823 var->children_requested = 0;
1824#endif
18231825
18241826 return var;
18251827}
18541854 xfree (var->root);
18551855 }
18561856
1857#ifdef HAVE_PYTHON
18571858 Py_XDECREF (var->value_formatter);
18581859 Py_XDECREF (var->children_lister);
1860#endif
18591861
18601862 xfree (var->name);
18611863 xfree (var->obj_name);
21302130}
21312131
21322132static char *
2133value_get_print_value (struct value *value, enum varobj_display_formats format,
2134 PyObject *value_formatter)
2133value_get_print_value (struct value *value, enum varobj_display_formats format
2134#ifdef HAVE_PYTHON
2135/* FIXME: this ifdef block is very ugly! */
2136 , PyObject *value_formatter
2137#endif
2138 )
21352139{
21362140 long dummy;
21372141 struct ui_file *stb;
21452145 if (value == NULL)
21462146 return NULL;
21472147
2148#ifdef HAVE_PYTHON
21482149 if (value_formatter)
21492150 {
21502151 /* FIXME: we *might* want to provide this functionality as
21822182 do_cleanups (back_to);
21832183 return xstrdup (s);
21842184 }
2185#endif /* HAVE_PYTHON */
21852186
21862187 stb = mem_fileopen ();
21872188 old_chain = make_cleanup_ui_file_delete (stb);
26432643 catch that case explicitly. */
26442644 struct type *type = get_type (var);
26452645
2646#ifdef HAVE_PYTHON
26462647 /* If we have a custom formatter, return whatever string it has
26472648 produced. */
26482649 if (var->value_formatter && var->print_value)
26492650 return xstrdup (var->print_value);
2651#endif
26502652
26512653 /* Strip top-level references. */
26522654 while (TYPE_CODE (type) == TYPE_CODE_REF)
toggle raw diff