616 int argc = context->
argc;
617 char **argv = context->
argv;
619 static int quiet = 0;
620 static int set_args = 0;
621 static int inhibit_home_gdbinit = 0;
625 char *execarg = NULL;
627 char *corearg = NULL;
628 char *pid_or_core_arg = NULL;
634 static int print_help;
635 static int print_version;
636 static int print_configuration;
639 std::vector<struct cmdarg> cmdarg_vec;
642 std::vector<char *> dirarg;
648#ifdef HAVE_USEFUL_SBRK
655#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
656 setlocale (LC_MESSAGES,
"");
658#if defined (HAVE_SETLOCALE)
659 setlocale (LC_CTYPE,
"");
662 bindtextdomain (
PACKAGE, LOCALEDIR);
671 setvbuf (stderr, NULL, _IONBF, BUFSIZ);
676 main_ui =
new ui (stdin, stdout, stderr);
683 if (bfd_init () != BFD_INIT_MAGIC)
684 error (_(
"fatal error: libbfd ABI mismatch"));
695 gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
699 current_directory = getcwd (NULL, 0);
700 if (current_directory == NULL)
716#ifdef WITH_PYTHON_LIBDIR
756 int write_files_1 = 0;
757 static struct option long_options[] =
759 {
"tui", no_argument, 0, OPT_TUI},
760 {
"readnow", no_argument, NULL, OPT_READNOW},
761 {
"readnever", no_argument, NULL, OPT_READNEVER},
762 {
"r", no_argument, NULL, OPT_READNOW},
763 {
"quiet", no_argument, &quiet, 1},
764 {
"q", no_argument, &quiet, 1},
765 {
"silent", no_argument, &quiet, 1},
766 {
"nh", no_argument, &inhibit_home_gdbinit, 1},
769 {
"batch-silent", no_argument, 0,
'B'},
775 {
"fullname", no_argument, 0,
'f'},
776 {
"f", no_argument, 0,
'f'},
778 {
"annotate", required_argument, 0, OPT_ANNOTATE},
779 {
"help", no_argument, &print_help, 1},
780 {
"se", required_argument, 0, OPT_SE},
781 {
"symbols", required_argument, 0,
's'},
782 {
"s", required_argument, 0,
's'},
783 {
"exec", required_argument, 0,
'e'},
784 {
"e", required_argument, 0,
'e'},
785 {
"core", required_argument, 0,
'c'},
786 {
"c", required_argument, 0,
'c'},
787 {
"pid", required_argument, 0,
'p'},
788 {
"p", required_argument, 0,
'p'},
789 {
"command", required_argument, 0,
'x'},
790 {
"eval-command", required_argument, 0,
'X'},
791 {
"version", no_argument, &print_version, 1},
792 {
"configuration", no_argument, &print_configuration, 1},
793 {
"x", required_argument, 0,
'x'},
794 {
"ex", required_argument, 0,
'X'},
795 {
"init-command", required_argument, 0, OPT_IX},
796 {
"init-eval-command", required_argument, 0, OPT_IEX},
797 {
"ix", required_argument, 0, OPT_IX},
798 {
"iex", required_argument, 0, OPT_IEX},
799 {
"early-init-command", required_argument, 0, OPT_EIX},
800 {
"early-init-eval-command", required_argument, 0, OPT_EIEX},
801 {
"eix", required_argument, 0, OPT_EIX},
802 {
"eiex", required_argument, 0, OPT_EIEX},
804 {
"tclcommand", required_argument, 0,
'z'},
805 {
"enable-external-editor", no_argument, 0,
'y'},
806 {
"editor-command", required_argument, 0,
'w'},
808 {
"ui", required_argument, 0,
'i'},
809 {
"interpreter", required_argument, 0,
'i'},
810 {
"i", required_argument, 0,
'i'},
811 {
"directory", required_argument, 0,
'd'},
812 {
"d", required_argument, 0,
'd'},
813 {
"data-directory", required_argument, 0,
'D'},
814 {
"D", required_argument, 0,
'D'},
815 {
"cd", required_argument, 0, OPT_CD},
816 {
"tty", required_argument, 0,
't'},
817 {
"baud", required_argument, 0,
'b'},
818 {
"b", required_argument, 0,
'b'},
819 {
"nw", no_argument, NULL, OPT_NOWINDOWS},
820 {
"nowindows", no_argument, NULL, OPT_NOWINDOWS},
821 {
"w", no_argument, NULL, OPT_WINDOWS},
822 {
"windows", no_argument, NULL, OPT_WINDOWS},
823 {
"statistics", no_argument, 0, OPT_STATISTICS},
824 {
"write", no_argument, &write_files_1, 1},
825 {
"args", no_argument, &set_args, 1},
826 {
"l", required_argument, 0,
'l'},
828 {0, no_argument, 0, 0}
835 c = getopt_long_only (argc, argv,
"",
836 long_options, &option_index);
837 if (c == EOF || set_args)
841 if (c == 0 && long_options[option_index].flag == 0)
842 c = long_options[option_index].val;
923 if (optarg[0] ==
'\0')
924 error (_(
"%s: empty path for `--data-directory'"),
932 if (!gdbtk_test (optarg))
933 error (_(
"%s: unable to load tclcommand file \"%s\""),
944 external_editor_command = xstrdup (optarg);
952 dirarg.push_back (optarg);
965 rate = strtol (optarg, &p, 0);
966 if (
rate == 0 && p == optarg)
967 warning (_(
"could not set baud rate to `%s'."),
978 timeout = strtol (optarg, &p, 0);
979 if (timeout == 0 && p == optarg)
980 warning (_(
"could not set timeout limit to `%s'."),
1002 error (_(
"Use `%s --help' for a complete list of options."),
1017 save_original_signals_state (quiet);
1020 gdb::alternate_signal_stack signal_stack;
1028 std::string home_gdbearlyinit;
1030 if (!home_gdbearlyinit.empty () && !inhibit_home_gdbinit)
1032 home_gdbearlyinit.c_str (), 0);
1053 error (_(
"%s: `--args' specified but no program specified"),
1056 symarg = argv[optind];
1057 execarg = argv[optind];
1069 symarg = argv[optind];
1070 execarg = argv[optind];
1078 if (pidarg == NULL && corearg == NULL && optind < argc)
1080 pid_or_core_arg = argv[optind];
1088 _(
"Excess command line "
1089 "arguments ignored. (%s%s)\n"),
1091 (optind == argc - 1) ?
"" :
" ...");
1097 std::vector<std::string> system_gdbinit;
1098 std::string home_gdbinit;
1099 std::string local_gdbinit;
1120 if (print_configuration)
1164 tmp_warn_preprint.reset ();
1173 for (
const std::string &file : system_gdbinit)
1182 if (!home_gdbinit.empty () && !
inhibit_gdbinit && !inhibit_home_gdbinit)
1194 for (i = 0; i < dirarg.size (); i++)
1205 && strcmp (execarg, symarg) == 0)
1218 if (execarg != NULL)
1226 if (corearg && pidarg)
1227 error (_(
"Can't attach to process and specify "
1228 "a core file at the same time."));
1230 if (corearg != NULL)
1235 else if (pidarg != NULL)
1239 else if (pid_or_core_arg)
1245 if (isdigit (pid_or_core_arg[0]))
1271 if (!local_gdbinit.empty ())
1274 = gdb_realpath (local_gdbinit.c_str ()).release ();
1279 local_gdbinit.c_str ());
1307 int error_status = EXIT_FAILURE;
1308 int *exit_arg = ret == 0 ? &error_status : NULL;
static void execute_cmdargs(const std::vector< struct cmdarg > *cmdarg_vec, cmdarg_kind file_type, cmdarg_kind cmd_type, int *ret)
static std::string relocate_path(const char *progname, const char *initial, bool relocatable)
static void get_init_files(std::vector< std::string > *system_gdbinit, std::string *home_gdbinit, std::string *local_gdbinit)
static int catch_command_errors(catch_command_errors_const_ftype command, const char *arg, int from_tty, bool do_bp_actions=false)