// True if CMD changes debugger settings bool is_setting_cmd (const string& cmd) { #if RUNTIME_REGEX static regex rxsetting_cmd("[ \t]*(set|dbxenv|O)[ \t]+.*"); static regex rxpath_cmd("[ \t]*(dir|directory|path)([ \t]+.*)?"); #endif if (is_set_args_cmd(cmd)) return false; // `set args' command return cmd.matches (rxsetting_cmd) || cmd.matches(rxpath_cmd); }
// If LINE is an argument-setting command, add it to the list of arguments void add_to_arguments(const string& line) { if (is_set_args_cmd(line)) { string args = line.after("args"); args = args.after(rxwhite); add_argument(args, run_arguments, last_run_argument, run_arguments_updated); } else if (gdb->type() == PERL && line.contains("@ARGV = ", 0)) { // @ARGV = ('arg1', 'arg2', ) string args = line.after("('"); args.gsub("', '", " "); args = args.before("', )"); add_argument(args, run_arguments, last_run_argument, run_arguments_updated); } else if (is_run_cmd(line)) { string args; if (gdb->type() == JDB) { // `run CLASS ARGS...' args = line.after(rxwhite); args = args.after(rxwhite); } else if (gdb->type() == PERL && line.contains("exec ", 0)) { // `exec "perl -d PROGRAM ARGS..."' args = line.after("exec "); strip_leading_space(args); if (args.contains('\"', 0) || args.contains('\'', 0)) args = unquote(args); args = args.after("-d "); strip_leading_space(args); args = args.after(rxwhite); } else { // `run ARGS...' args = line.after(rxwhite); } add_argument(args, run_arguments, last_run_argument, run_arguments_updated); } else if (is_make_cmd(line)) { string args = line.after("make"); args = args.after(rxwhite); add_argument(args, make_arguments, last_make_argument, make_arguments_updated); } else if (gdb->type() == PERL && line.contains("system 'make", 0)) { string args = line.after("make"); args = args.after(rxwhite); args = args.before("'"); add_argument(args, make_arguments, last_make_argument, make_arguments_updated); } else if (is_cd_cmd(line)) { string dir = line.after("cd"); dir = dir.after(rxwhite); dir = source_view->full_path(dir); if (dir.contains('/', 0)) add_argument(dir, cd_arguments, last_cd_argument, cd_arguments_updated); } else if (gdb->type() == PERL && line.contains("chdir '", 0)) { string dir = line.after("'"); dir = dir.before("'"); add_argument(dir, cd_arguments, last_cd_argument, cd_arguments_updated); } else if (gdb->type() == PERL && is_file_cmd(line, gdb)) { string args = line.after(" -d "); args = args.after(rxwhite); // Skip file name args = args.before('\"'); add_argument(args, run_arguments, last_run_argument, run_arguments_updated); } }