/* Add one or more directories to start of executable search path. */ enum mi_cmd_result mi_cmd_env_path (char *command, char **argv, int argc) { char *exec_path; const char *env; int reset = 0; int optind = 0; int i; char *optarg; enum opt { RESET_OPT }; static struct mi_opt opts[] = { { "r", RESET_OPT, 0 }, { NULL, 0, 0 } }; dont_repeat(); if (mi_version(uiout) < 2) { for (i = (argc - 1); i >= 0; --i) env_execute_cli_command("path", argv[i]); return MI_CMD_DONE; } /* Otherwise the mi level is 2 or higher. */ while (1) { int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts, &optind, &optarg); if (opt < 0) break; switch ((enum opt)opt) { case RESET_OPT: reset = 1; break; default: break; } } argv += optind; argc -= optind; if (reset) { /* Reset implies resetting to original path first. */ exec_path = xstrdup (orig_path); } else { /* Otherwise, get current path to modify. */ env = get_in_environ (inferior_environ, path_var_name); /* Can be null if path is not set. */ if (!env) env = ""; exec_path = xstrdup (env); } for (i = argc - 1; i >= 0; --i) env_mod_path (argv[i], &exec_path); set_in_environ (inferior_environ, path_var_name, exec_path); xfree (exec_path); env = get_in_environ (inferior_environ, path_var_name); ui_out_field_string (uiout, "path", env); return MI_CMD_DONE; }
/* Print a list of the locals or the arguments for the currently selected frame. If the argument passed is 0, printonly the names of the variables, if an argument of 1 is passed, print the values as well. */ static void list_args_or_locals (int locals, int values, struct frame_info *fi) { struct block *block; struct symbol *sym; struct dict_iterator iter; int nsyms; struct cleanup *cleanup_list; static struct ui_stream *stb = NULL; struct type *type; stb = ui_out_stream_new (uiout); block = get_frame_block (fi, 0); cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args"); while (block != 0) { ALL_BLOCK_SYMBOLS (block, iter, sym) { int print_me = 0; switch (SYMBOL_CLASS (sym)) { default: case LOC_UNDEF: /* catches errors */ case LOC_CONST: /* constant */ case LOC_TYPEDEF: /* local typedef */ case LOC_LABEL: /* local label */ case LOC_BLOCK: /* local function */ case LOC_CONST_BYTES: /* loc. byte seq. */ case LOC_UNRESOLVED: /* unresolved static */ case LOC_OPTIMIZED_OUT: /* optimized out */ print_me = 0; break; case LOC_ARG: /* argument */ case LOC_REF_ARG: /* reference arg */ case LOC_REGPARM: /* register arg */ case LOC_REGPARM_ADDR: /* indirect register arg */ case LOC_LOCAL_ARG: /* stack arg */ case LOC_BASEREG_ARG: /* basereg arg */ case LOC_COMPUTED_ARG: /* arg with computed location */ if (!locals) print_me = 1; break; case LOC_LOCAL: /* stack local */ case LOC_BASEREG: /* basereg local */ case LOC_STATIC: /* static */ case LOC_REGISTER: /* register */ case LOC_COMPUTED: /* computed location */ if (locals) print_me = 1; break; } if (print_me) { struct cleanup *cleanup_tuple = NULL; struct symbol *sym2; if (values != PRINT_NO_VALUES) cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym)); if (!locals) sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym), block, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); else sym2 = sym; switch (values) { case PRINT_SIMPLE_VALUES: type = check_typedef (sym2->type); type_print (sym2->type, "", stb->stream, -1); ui_out_field_stream (uiout, "type", stb); if (TYPE_CODE (type) != TYPE_CODE_ARRAY && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION) { print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); } do_cleanups (cleanup_tuple); break; case PRINT_ALL_VALUES: print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); do_cleanups (cleanup_tuple); break; } } } if (BLOCK_FUNCTION (block)) break; else block = BLOCK_SUPERBLOCK (block); }