| OLD | NEW |
| 1 /* Top level stuff for GDB, the GNU debugger. | 1 /* Top level stuff for GDB, the GNU debugger. |
| 2 | 2 |
| 3 Copyright (C) 1986-2005, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1986-2005, 2007-2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "gdb_string.h" | 34 #include "gdb_string.h" |
| 35 #include "event-loop.h" | 35 #include "event-loop.h" |
| 36 #include "ui-out.h" | 36 #include "ui-out.h" |
| 37 | 37 |
| 38 #include "interps.h" | 38 #include "interps.h" |
| 39 #include "main.h" | 39 #include "main.h" |
| 40 #include "source.h" | 40 #include "source.h" |
| 41 #include "cli/cli-cmds.h" | 41 #include "cli/cli-cmds.h" |
| 42 #include "python/python.h" | 42 #include "python/python.h" |
| 43 #include "objfiles.h" | 43 #include "objfiles.h" |
| 44 #include "auto-load.h" |
| 44 | 45 |
| 45 /* The selected interpreter. This will be used as a set command | 46 /* The selected interpreter. This will be used as a set command |
| 46 variable, so it should always be malloc'ed - since | 47 variable, so it should always be malloc'ed - since |
| 47 do_setshow_command will free it. */ | 48 do_setshow_command will free it. */ |
| 48 char *interpreter_p; | 49 char *interpreter_p; |
| 49 | 50 |
| 50 /* Whether xdb commands will be handled. */ | 51 /* Whether xdb commands will be handled. */ |
| 51 int xdb_commands = 0; | 52 int xdb_commands = 0; |
| 52 | 53 |
| 53 /* Whether dbx commands will be handled. */ | 54 /* Whether dbx commands will be handled. */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 /* Support for the --batch-silent option. */ | 79 /* Support for the --batch-silent option. */ |
| 79 int batch_silent = 0; | 80 int batch_silent = 0; |
| 80 | 81 |
| 81 /* Support for --return-child-result option. | 82 /* Support for --return-child-result option. |
| 82 Set the default to -1 to return error in the case | 83 Set the default to -1 to return error in the case |
| 83 that the program does not run or does not complete. */ | 84 that the program does not run or does not complete. */ |
| 84 int return_child_result = 0; | 85 int return_child_result = 0; |
| 85 int return_child_result_value = -1; | 86 int return_child_result_value = -1; |
| 86 | 87 |
| 87 /* Whether to enable writing into executable and core files. */ | |
| 88 extern int write_files; | |
| 89 | 88 |
| 90 /* GDB as it has been invoked from the command line (i.e. argv[0]). */ | 89 /* GDB as it has been invoked from the command line (i.e. argv[0]). */ |
| 91 static char *gdb_program_name; | 90 static char *gdb_program_name; |
| 92 | 91 |
| 93 static void print_gdb_help (struct ui_file *); | 92 static void print_gdb_help (struct ui_file *); |
| 94 | 93 |
| 95 /* These two are used to set the external editor commands when gdb is | |
| 96 farming out files to be edited by another program. */ | |
| 97 | |
| 98 extern char *external_editor_command; | |
| 99 | |
| 100 /* Relocate a file or directory. PROGNAME is the name by which gdb | 94 /* Relocate a file or directory. PROGNAME is the name by which gdb |
| 101 was invoked (i.e., argv[0]). INITIAL is the default value for the | 95 was invoked (i.e., argv[0]). INITIAL is the default value for the |
| 102 file or directory. FLAG is true if the value is relocatable, false | 96 file or directory. FLAG is true if the value is relocatable, false |
| 103 otherwise. Returns a newly allocated string; this may return NULL | 97 otherwise. Returns a newly allocated string; this may return NULL |
| 104 under the same conditions as make_relative_prefix. */ | 98 under the same conditions as make_relative_prefix. */ |
| 105 | 99 |
| 106 static char * | 100 static char * |
| 107 relocate_path (const char *progname, const char *initial, int flag) | 101 relocate_path (const char *progname, const char *initial, int flag) |
| 108 { | 102 { |
| 109 if (flag) | 103 if (flag) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 interpreter_async = 1; | 224 interpreter_async = 1; |
| 231 | 225 |
| 232 current_interp_command_loop (); | 226 current_interp_command_loop (); |
| 233 /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton | 227 /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton |
| 234 would clean things up (restoring the cleanup chain) to the state | 228 would clean things up (restoring the cleanup chain) to the state |
| 235 they were just prior to the call. Technically, this means that | 229 they were just prior to the call. Technically, this means that |
| 236 the do_cleanups() below is redundant. Unfortunately, many FUNCs | 230 the do_cleanups() below is redundant. Unfortunately, many FUNCs |
| 237 are not that well behaved. do_cleanups should either be replaced | 231 are not that well behaved. do_cleanups should either be replaced |
| 238 with a do_cleanups call (to cover the problem) or an assertion | 232 with a do_cleanups call (to cover the problem) or an assertion |
| 239 check to detect bad FUNCs code. */ | 233 check to detect bad FUNCs code. */ |
| 240 do_cleanups (ALL_CLEANUPS); | 234 do_cleanups (all_cleanups ()); |
| 241 /* If the command_loop returned, normally (rather than threw an | 235 /* If the command_loop returned, normally (rather than threw an |
| 242 error) we try to quit. If the quit is aborted, catch_errors() | 236 error) we try to quit. If the quit is aborted, catch_errors() |
| 243 which called this catch the signal and restart the command | 237 which called this catch the signal and restart the command |
| 244 loop. */ | 238 loop. */ |
| 245 quit_command (NULL, instream == stdin); | 239 quit_command (NULL, instream == stdin); |
| 246 return 1; | 240 return 1; |
| 247 } | 241 } |
| 248 | 242 |
| 243 /* Arguments of --command option and its counterpart. */ |
| 244 typedef struct cmdarg { |
| 245 /* Type of this option. */ |
| 246 enum { |
| 247 /* Option type -x. */ |
| 248 CMDARG_FILE, |
| 249 |
| 250 /* Option type -ex. */ |
| 251 CMDARG_COMMAND, |
| 252 |
| 253 /* Option type -ix. */ |
| 254 CMDARG_INIT_FILE, |
| 255 |
| 256 /* Option type -iex. */ |
| 257 CMDARG_INIT_COMMAND |
| 258 } type; |
| 259 |
| 260 /* Value of this option - filename or the GDB command itself. String memory |
| 261 is not owned by this structure despite it is 'const'. */ |
| 262 char *string; |
| 263 } cmdarg_s; |
| 264 |
| 265 /* Define type VEC (cmdarg_s). */ |
| 266 DEF_VEC_O (cmdarg_s); |
| 267 |
| 249 static int | 268 static int |
| 250 captured_main (void *data) | 269 captured_main (void *data) |
| 251 { | 270 { |
| 252 struct captured_main_args *context = data; | 271 struct captured_main_args *context = data; |
| 253 int argc = context->argc; | 272 int argc = context->argc; |
| 254 char **argv = context->argv; | 273 char **argv = context->argv; |
| 255 static int quiet = 0; | 274 static int quiet = 0; |
| 256 static int set_args = 0; | 275 static int set_args = 0; |
| 257 | 276 |
| 258 /* Pointers to various arguments from command line. */ | 277 /* Pointers to various arguments from command line. */ |
| 259 char *symarg = NULL; | 278 char *symarg = NULL; |
| 260 char *execarg = NULL; | 279 char *execarg = NULL; |
| 261 char *pidarg = NULL; | 280 char *pidarg = NULL; |
| 262 char *corearg = NULL; | 281 char *corearg = NULL; |
| 263 char *pid_or_core_arg = NULL; | 282 char *pid_or_core_arg = NULL; |
| 264 char *cdarg = NULL; | 283 char *cdarg = NULL; |
| 265 char *ttyarg = NULL; | 284 char *ttyarg = NULL; |
| 266 | 285 |
| 267 /* These are static so that we can take their address in an | 286 /* These are static so that we can take their address in an |
| 268 initializer. */ | 287 initializer. */ |
| 269 static int print_help; | 288 static int print_help; |
| 270 static int print_version; | 289 static int print_version; |
| 271 | 290 |
| 272 /* Pointers to all arguments of --command option. */ | 291 /* Pointers to all arguments of --command option. */ |
| 273 struct cmdarg { | 292 VEC (cmdarg_s) *cmdarg_vec = NULL; |
| 274 enum { | 293 struct cmdarg *cmdarg_p; |
| 275 CMDARG_FILE, | |
| 276 CMDARG_COMMAND | |
| 277 } type; | |
| 278 char *string; | |
| 279 } *cmdarg; | |
| 280 /* Allocated size of cmdarg. */ | |
| 281 int cmdsize; | |
| 282 /* Number of elements of cmdarg used. */ | |
| 283 int ncmd; | |
| 284 | 294 |
| 285 /* Indices of all arguments of --directory option. */ | 295 /* Indices of all arguments of --directory option. */ |
| 286 char **dirarg; | 296 char **dirarg; |
| 287 /* Allocated size. */ | 297 /* Allocated size. */ |
| 288 int dirsize; | 298 int dirsize; |
| 289 /* Number of elements used. */ | 299 /* Number of elements used. */ |
| 290 int ndir; | 300 int ndir; |
| 291 | 301 |
| 292 /* gdb init files. */ | 302 /* gdb init files. */ |
| 293 char *system_gdbinit; | 303 char *system_gdbinit; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 309 | 319 |
| 310 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) | 320 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) |
| 311 setlocale (LC_MESSAGES, ""); | 321 setlocale (LC_MESSAGES, ""); |
| 312 #endif | 322 #endif |
| 313 #if defined (HAVE_SETLOCALE) | 323 #if defined (HAVE_SETLOCALE) |
| 314 setlocale (LC_CTYPE, ""); | 324 setlocale (LC_CTYPE, ""); |
| 315 #endif | 325 #endif |
| 316 bindtextdomain (PACKAGE, LOCALEDIR); | 326 bindtextdomain (PACKAGE, LOCALEDIR); |
| 317 textdomain (PACKAGE); | 327 textdomain (PACKAGE); |
| 318 | 328 |
| 319 cmdsize = 1; | 329 make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec); |
| 320 cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg)); | |
| 321 ncmd = 0; | |
| 322 dirsize = 1; | 330 dirsize = 1; |
| 323 dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); | 331 dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); |
| 324 ndir = 0; | 332 ndir = 0; |
| 325 | 333 |
| 326 quit_flag = 0; | 334 quit_flag = 0; |
| 327 saved_command_line = (char *) xmalloc (saved_command_line_size); | 335 saved_command_line = (char *) xmalloc (saved_command_line_size); |
| 328 saved_command_line[0] = '\0'; | 336 saved_command_line[0] = '\0'; |
| 329 instream = stdin; | 337 instream = stdin; |
| 330 | 338 |
| 331 gdb_stdout = stdio_fileopen (stdout); | 339 gdb_stdout = stdio_fileopen (stdout); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 /* When var field is 0, use flag field to record the equivalent | 394 /* When var field is 0, use flag field to record the equivalent |
| 387 short option (or arbitrary numbers starting at 10 for those | 395 short option (or arbitrary numbers starting at 10 for those |
| 388 with no equivalent). */ | 396 with no equivalent). */ |
| 389 enum { | 397 enum { |
| 390 OPT_SE = 10, | 398 OPT_SE = 10, |
| 391 OPT_CD, | 399 OPT_CD, |
| 392 OPT_ANNOTATE, | 400 OPT_ANNOTATE, |
| 393 OPT_STATISTICS, | 401 OPT_STATISTICS, |
| 394 OPT_TUI, | 402 OPT_TUI, |
| 395 OPT_NOWINDOWS, | 403 OPT_NOWINDOWS, |
| 396 OPT_WINDOWS | 404 OPT_WINDOWS, |
| 405 OPT_IX, |
| 406 OPT_IEX |
| 397 }; | 407 }; |
| 398 static struct option long_options[] = | 408 static struct option long_options[] = |
| 399 { | 409 { |
| 400 {"tui", no_argument, 0, OPT_TUI}, | 410 {"tui", no_argument, 0, OPT_TUI}, |
| 401 {"xdb", no_argument, &xdb_commands, 1}, | 411 {"xdb", no_argument, &xdb_commands, 1}, |
| 402 {"dbx", no_argument, &dbx_commands, 1}, | 412 {"dbx", no_argument, &dbx_commands, 1}, |
| 403 {"readnow", no_argument, &readnow_symbol_files, 1}, | 413 {"readnow", no_argument, &readnow_symbol_files, 1}, |
| 404 {"r", no_argument, &readnow_symbol_files, 1}, | 414 {"r", no_argument, &readnow_symbol_files, 1}, |
| 405 {"quiet", no_argument, &quiet, 1}, | 415 {"quiet", no_argument, &quiet, 1}, |
| 406 {"q", no_argument, &quiet, 1}, | 416 {"q", no_argument, &quiet, 1}, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 426 {"e", required_argument, 0, 'e'}, | 436 {"e", required_argument, 0, 'e'}, |
| 427 {"core", required_argument, 0, 'c'}, | 437 {"core", required_argument, 0, 'c'}, |
| 428 {"c", required_argument, 0, 'c'}, | 438 {"c", required_argument, 0, 'c'}, |
| 429 {"pid", required_argument, 0, 'p'}, | 439 {"pid", required_argument, 0, 'p'}, |
| 430 {"p", required_argument, 0, 'p'}, | 440 {"p", required_argument, 0, 'p'}, |
| 431 {"command", required_argument, 0, 'x'}, | 441 {"command", required_argument, 0, 'x'}, |
| 432 {"eval-command", required_argument, 0, 'X'}, | 442 {"eval-command", required_argument, 0, 'X'}, |
| 433 {"version", no_argument, &print_version, 1}, | 443 {"version", no_argument, &print_version, 1}, |
| 434 {"x", required_argument, 0, 'x'}, | 444 {"x", required_argument, 0, 'x'}, |
| 435 {"ex", required_argument, 0, 'X'}, | 445 {"ex", required_argument, 0, 'X'}, |
| 446 {"init-command", required_argument, 0, OPT_IX}, |
| 447 {"init-eval-command", required_argument, 0, OPT_IEX}, |
| 448 {"ix", required_argument, 0, OPT_IX}, |
| 449 {"iex", required_argument, 0, OPT_IEX}, |
| 436 #ifdef GDBTK | 450 #ifdef GDBTK |
| 437 {"tclcommand", required_argument, 0, 'z'}, | 451 {"tclcommand", required_argument, 0, 'z'}, |
| 438 {"enable-external-editor", no_argument, 0, 'y'}, | 452 {"enable-external-editor", no_argument, 0, 'y'}, |
| 439 {"editor-command", required_argument, 0, 'w'}, | 453 {"editor-command", required_argument, 0, 'w'}, |
| 440 #endif | 454 #endif |
| 441 {"ui", required_argument, 0, 'i'}, | 455 {"ui", required_argument, 0, 'i'}, |
| 442 {"interpreter", required_argument, 0, 'i'}, | 456 {"interpreter", required_argument, 0, 'i'}, |
| 443 {"i", required_argument, 0, 'i'}, | 457 {"i", required_argument, 0, 'i'}, |
| 444 {"directory", required_argument, 0, 'd'}, | 458 {"directory", required_argument, 0, 'd'}, |
| 445 {"d", required_argument, 0, 'd'}, | 459 {"d", required_argument, 0, 'd'}, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 case 'e': | 548 case 'e': |
| 535 execarg = optarg; | 549 execarg = optarg; |
| 536 break; | 550 break; |
| 537 case 'c': | 551 case 'c': |
| 538 corearg = optarg; | 552 corearg = optarg; |
| 539 break; | 553 break; |
| 540 case 'p': | 554 case 'p': |
| 541 pidarg = optarg; | 555 pidarg = optarg; |
| 542 break; | 556 break; |
| 543 case 'x': | 557 case 'x': |
| 544 » cmdarg[ncmd].type = CMDARG_FILE; | 558 » { |
| 545 » cmdarg[ncmd++].string = optarg; | 559 » struct cmdarg cmdarg = { CMDARG_FILE, optarg }; |
| 546 » if (ncmd >= cmdsize) | 560 |
| 547 » { | 561 » VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); |
| 548 » » cmdsize *= 2; | 562 » } |
| 549 » » cmdarg = xrealloc ((char *) cmdarg, | |
| 550 » » » » cmdsize * sizeof (*cmdarg)); | |
| 551 » } | |
| 552 break; | 563 break; |
| 553 case 'X': | 564 case 'X': |
| 554 » cmdarg[ncmd].type = CMDARG_COMMAND; | 565 » { |
| 555 » cmdarg[ncmd++].string = optarg; | 566 » struct cmdarg cmdarg = { CMDARG_COMMAND, optarg }; |
| 556 » if (ncmd >= cmdsize) | 567 |
| 557 » { | 568 » VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); |
| 558 » » cmdsize *= 2; | 569 » } |
| 559 » » cmdarg = xrealloc ((char *) cmdarg, | 570 » break; |
| 560 » » » » cmdsize * sizeof (*cmdarg)); | 571 » case OPT_IX: |
| 561 » } | 572 » { |
| 573 » struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg }; |
| 574 |
| 575 » VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); |
| 576 » } |
| 577 » break; |
| 578 » case OPT_IEX: |
| 579 » { |
| 580 » struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg }; |
| 581 |
| 582 » VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); |
| 583 » } |
| 562 break; | 584 break; |
| 563 case 'B': | 585 case 'B': |
| 564 batch_flag = batch_silent = 1; | 586 batch_flag = batch_silent = 1; |
| 565 gdb_stdout = ui_file_new(); | 587 gdb_stdout = ui_file_new(); |
| 566 break; | 588 break; |
| 567 case 'D': | 589 case 'D': |
| 568 xfree (gdb_datadir); | 590 xfree (gdb_datadir); |
| 569 gdb_datadir = xstrdup (optarg); | 591 gdb_datadir = xstrdup (optarg); |
| 570 break; | 592 break; |
| 571 #ifdef GDBTK | 593 #ifdef GDBTK |
| 572 case 'z': | 594 case 'z': |
| 573 { | 595 { |
| 574 extern int gdbtk_test (char *); | 596 extern int gdbtk_test (char *); |
| 575 | 597 |
| 576 if (!gdbtk_test (optarg)) | 598 if (!gdbtk_test (optarg)) |
| 577 { | 599 { |
| 578 fprintf_unfiltered (gdb_stderr, | 600 fprintf_unfiltered (gdb_stderr, |
| 579 _("%s: unable to load " | 601 _("%s: unable to load " |
| 580 "tclcommand file \"%s\""), | 602 "tclcommand file \"%s\""), |
| 581 argv[0], optarg); | 603 argv[0], optarg); |
| 582 exit (1); | 604 exit (1); |
| 583 } | 605 } |
| 584 break; | 606 break; |
| 585 } | 607 } |
| 586 case 'y': | 608 case 'y': |
| 587 /* Backwards compatibility only. */ | 609 /* Backwards compatibility only. */ |
| 588 break; | 610 break; |
| 589 case 'w': | 611 case 'w': |
| 590 { | 612 { |
| 613 /* Set the external editor commands when gdb is farming out files |
| 614 to be edited by another program. */ |
| 615 extern char *external_editor_command; |
| 616 |
| 591 external_editor_command = xstrdup (optarg); | 617 external_editor_command = xstrdup (optarg); |
| 592 break; | 618 break; |
| 593 } | 619 } |
| 594 #endif /* GDBTK */ | 620 #endif /* GDBTK */ |
| 595 case 'i': | 621 case 'i': |
| 596 xfree (interpreter_p); | 622 xfree (interpreter_p); |
| 597 interpreter_p = xstrdup (optarg); | 623 interpreter_p = xstrdup (optarg); |
| 598 break; | 624 break; |
| 599 case 'd': | 625 case 'd': |
| 600 dirarg[ndir++] = optarg; | 626 dirarg[ndir++] = optarg; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 catch_command_errors (source_script, system_gdbinit, 0, RETURN_MASK_ALL); | 841 catch_command_errors (source_script, system_gdbinit, 0, RETURN_MASK_ALL); |
| 816 | 842 |
| 817 /* Read and execute $HOME/.gdbinit file, if it exists. This is done | 843 /* Read and execute $HOME/.gdbinit file, if it exists. This is done |
| 818 *before* all the command line arguments are processed; it sets | 844 *before* all the command line arguments are processed; it sets |
| 819 global parameters, which are independent of what file you are | 845 global parameters, which are independent of what file you are |
| 820 debugging or what directory you are in. */ | 846 debugging or what directory you are in. */ |
| 821 | 847 |
| 822 if (home_gdbinit && !inhibit_gdbinit) | 848 if (home_gdbinit && !inhibit_gdbinit) |
| 823 catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL); | 849 catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL); |
| 824 | 850 |
| 851 /* Process '-ix' and '-iex' options early. */ |
| 852 for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) |
| 853 switch (cmdarg_p->type) |
| 854 { |
| 855 case CMDARG_INIT_FILE: |
| 856 catch_command_errors (source_script, cmdarg_p->string, |
| 857 !batch_flag, RETURN_MASK_ALL); |
| 858 break; |
| 859 case CMDARG_INIT_COMMAND: |
| 860 catch_command_errors (execute_command, cmdarg_p->string, |
| 861 !batch_flag, RETURN_MASK_ALL); |
| 862 break; |
| 863 } |
| 864 |
| 825 /* Now perform all the actions indicated by the arguments. */ | 865 /* Now perform all the actions indicated by the arguments. */ |
| 826 if (cdarg != NULL) | 866 if (cdarg != NULL) |
| 827 { | 867 { |
| 828 catch_command_errors (cd_command, cdarg, 0, RETURN_MASK_ALL); | 868 catch_command_errors (cd_command, cdarg, 0, RETURN_MASK_ALL); |
| 829 } | 869 } |
| 830 | 870 |
| 831 for (i = 0; i < ndir; i++) | 871 for (i = 0; i < ndir; i++) |
| 832 catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL); | 872 catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL); |
| 833 xfree (dirarg); | 873 xfree (dirarg); |
| 834 | 874 |
| 835 /* Skip auto-loading section-specified scripts until we've sourced | 875 /* Skip auto-loading section-specified scripts until we've sourced |
| 836 local_gdbinit (which is often used to augment the source search | 876 local_gdbinit (which is often used to augment the source search |
| 837 path). */ | 877 path). */ |
| 838 save_auto_load = gdbpy_global_auto_load; | 878 save_auto_load = global_auto_load; |
| 839 gdbpy_global_auto_load = 0; | 879 global_auto_load = 0; |
| 840 | 880 |
| 841 if (execarg != NULL | 881 if (execarg != NULL |
| 842 && symarg != NULL | 882 && symarg != NULL |
| 843 && strcmp (execarg, symarg) == 0) | 883 && strcmp (execarg, symarg) == 0) |
| 844 { | 884 { |
| 845 /* The exec file and the symbol-file are the same. If we can't | 885 /* The exec file and the symbol-file are the same. If we can't |
| 846 open it, better only print one error message. | 886 open it, better only print one error message. |
| 847 catch_command_errors returns non-zero on success! */ | 887 catch_command_errors returns non-zero on success! */ |
| 848 if (catch_command_errors (exec_file_attach, execarg, | 888 if (catch_command_errors (exec_file_attach, execarg, |
| 849 !batch_flag, RETURN_MASK_ALL)) | 889 !batch_flag, RETURN_MASK_ALL)) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 if (ttyarg != NULL) | 931 if (ttyarg != NULL) |
| 892 set_inferior_io_terminal (ttyarg); | 932 set_inferior_io_terminal (ttyarg); |
| 893 | 933 |
| 894 /* Error messages should no longer be distinguished with extra output. */ | 934 /* Error messages should no longer be distinguished with extra output. */ |
| 895 error_pre_print = NULL; | 935 error_pre_print = NULL; |
| 896 quit_pre_print = NULL; | 936 quit_pre_print = NULL; |
| 897 warning_pre_print = _("warning: "); | 937 warning_pre_print = _("warning: "); |
| 898 | 938 |
| 899 /* Read the .gdbinit file in the current directory, *if* it isn't | 939 /* Read the .gdbinit file in the current directory, *if* it isn't |
| 900 the same as the $HOME/.gdbinit file (it should exist, also). */ | 940 the same as the $HOME/.gdbinit file (it should exist, also). */ |
| 901 if (local_gdbinit && !inhibit_gdbinit) | 941 if (local_gdbinit) |
| 902 catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); | 942 { |
| 943 auto_load_local_gdbinit_pathname = gdb_realpath (local_gdbinit); |
| 944 |
| 945 if (!inhibit_gdbinit && auto_load_local_gdbinit |
| 946 » && file_is_auto_load_safe (local_gdbinit, |
| 947 » » » » _("auto-load: Loading .gdbinit " |
| 948 » » » » "file \"%s\".\n"), |
| 949 » » » » local_gdbinit)) |
| 950 » { |
| 951 » auto_load_local_gdbinit_loaded = 1; |
| 952 |
| 953 » catch_command_errors (source_script, local_gdbinit, 0, |
| 954 » » » » RETURN_MASK_ALL); |
| 955 » } |
| 956 } |
| 903 | 957 |
| 904 /* Now that all .gdbinit's have been read and all -d options have been | 958 /* Now that all .gdbinit's have been read and all -d options have been |
| 905 processed, we can read any scripts mentioned in SYMARG. | 959 processed, we can read any scripts mentioned in SYMARG. |
| 906 We wait until now because it is common to add to the source search | 960 We wait until now because it is common to add to the source search |
| 907 path in local_gdbinit. */ | 961 path in local_gdbinit. */ |
| 908 gdbpy_global_auto_load = save_auto_load; | 962 global_auto_load = save_auto_load; |
| 909 ALL_OBJFILES (objfile) | 963 ALL_OBJFILES (objfile) |
| 910 load_auto_scripts_for_objfile (objfile); | 964 load_auto_scripts_for_objfile (objfile); |
| 911 | 965 |
| 912 for (i = 0; i < ncmd; i++) | 966 /* Process '-x' and '-ex' options. */ |
| 967 for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) |
| 968 switch (cmdarg_p->type) |
| 913 { | 969 { |
| 914 if (cmdarg[i].type == CMDARG_FILE) | 970 case CMDARG_FILE: |
| 915 catch_command_errors (source_script, cmdarg[i].string, | 971 catch_command_errors (source_script, cmdarg_p->string, |
| 916 !batch_flag, RETURN_MASK_ALL); | 972 !batch_flag, RETURN_MASK_ALL); |
| 917 else /* cmdarg[i].type == CMDARG_COMMAND */ | 973 » break; |
| 918 catch_command_errors (execute_command, cmdarg[i].string, | 974 case CMDARG_COMMAND: |
| 975 catch_command_errors (execute_command, cmdarg_p->string, |
| 919 !batch_flag, RETURN_MASK_ALL); | 976 !batch_flag, RETURN_MASK_ALL); |
| 977 break; |
| 920 } | 978 } |
| 921 xfree (cmdarg); | |
| 922 | 979 |
| 923 /* Read in the old history after all the command files have been | 980 /* Read in the old history after all the command files have been |
| 924 read. */ | 981 read. */ |
| 925 init_history (); | 982 init_history (); |
| 926 | 983 |
| 927 if (batch_flag) | 984 if (batch_flag) |
| 928 { | 985 { |
| 929 /* We have hit the end of the batch file. */ | 986 /* We have hit the end of the batch file. */ |
| 930 quit_force (NULL, 0); | 987 quit_force (NULL, 0); |
| 931 } | 988 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 --batch Exit after processing options.\n\ | 1039 --batch Exit after processing options.\n\ |
| 983 --batch-silent As for --batch, but suppress all gdb stdout output.\n\ | 1040 --batch-silent As for --batch, but suppress all gdb stdout output.\n\ |
| 984 --return-child-result\n\ | 1041 --return-child-result\n\ |
| 985 GDB exit code will be the child's exit code.\n\ | 1042 GDB exit code will be the child's exit code.\n\ |
| 986 --cd=DIR Change current directory to DIR.\n\ | 1043 --cd=DIR Change current directory to DIR.\n\ |
| 987 --command=FILE, -x Execute GDB commands from FILE.\n\ | 1044 --command=FILE, -x Execute GDB commands from FILE.\n\ |
| 988 --eval-command=COMMAND, -ex\n\ | 1045 --eval-command=COMMAND, -ex\n\ |
| 989 Execute a single GDB command.\n\ | 1046 Execute a single GDB command.\n\ |
| 990 May be used multiple times and in conjunction\n\ | 1047 May be used multiple times and in conjunction\n\ |
| 991 with --command.\n\ | 1048 with --command.\n\ |
| 1049 --init-command=FILE, -ix Like -x but execute it before loading inferior.\n\ |
| 1050 --init-eval-command=COMMAND, -iex Like -ex but before loading inferior.\n\ |
| 992 --core=COREFILE Analyze the core dump COREFILE.\n\ | 1051 --core=COREFILE Analyze the core dump COREFILE.\n\ |
| 993 --pid=PID Attach to running process PID.\n\ | 1052 --pid=PID Attach to running process PID.\n\ |
| 994 "), stream); | 1053 "), stream); |
| 995 fputs_unfiltered (_("\ | 1054 fputs_unfiltered (_("\ |
| 996 --dbx DBX compatibility mode.\n\ | 1055 --dbx DBX compatibility mode.\n\ |
| 997 --directory=DIR Search for source files in DIR.\n\ | 1056 --directory=DIR Search for source files in DIR.\n\ |
| 998 --epoch Output information used by epoch emacs-GDB interface.\n\ | 1057 --epoch Output information used by epoch emacs-GDB interface.\n\ |
| 999 --exec=EXECFILE Use EXECFILE as the executable.\n\ | 1058 --exec=EXECFILE Use EXECFILE as the executable.\n\ |
| 1000 --fullname Output information used by emacs-GDB interface.\n\ | 1059 --fullname Output information used by emacs-GDB interface.\n\ |
| 1001 --help Print this message.\n\ | 1060 --help Print this message.\n\ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 if (system_gdbinit) | 1094 if (system_gdbinit) |
| 1036 fprintf_unfiltered (stream, _("\ | 1095 fprintf_unfiltered (stream, _("\ |
| 1037 * system-wide init file: %s\n\ | 1096 * system-wide init file: %s\n\ |
| 1038 "), system_gdbinit); | 1097 "), system_gdbinit); |
| 1039 if (home_gdbinit) | 1098 if (home_gdbinit) |
| 1040 fprintf_unfiltered (stream, _("\ | 1099 fprintf_unfiltered (stream, _("\ |
| 1041 * user-specific init file: %s\n\ | 1100 * user-specific init file: %s\n\ |
| 1042 "), home_gdbinit); | 1101 "), home_gdbinit); |
| 1043 if (local_gdbinit) | 1102 if (local_gdbinit) |
| 1044 fprintf_unfiltered (stream, _("\ | 1103 fprintf_unfiltered (stream, _("\ |
| 1045 * local init file: ./%s\n\ | 1104 * local init file (see also 'set auto-load local-gdbinit'): ./%s\n\ |
| 1046 "), local_gdbinit); | 1105 "), local_gdbinit); |
| 1047 fputs_unfiltered (_("\n\ | 1106 fputs_unfiltered (_("\n\ |
| 1048 For more information, type \"help\" from within GDB, or consult the\n\ | 1107 For more information, type \"help\" from within GDB, or consult the\n\ |
| 1049 GDB manual (available as on-line info or a printed manual).\n\ | 1108 GDB manual (available as on-line info or a printed manual).\n\ |
| 1050 "), stream); | 1109 "), stream); |
| 1051 if (REPORT_BUGS_TO[0] && stream == gdb_stdout) | 1110 if (REPORT_BUGS_TO[0] && stream == gdb_stdout) |
| 1052 fprintf_unfiltered (stream, _("\ | 1111 fprintf_unfiltered (stream, _("\ |
| 1053 Report bugs to \"%s\".\n\ | 1112 Report bugs to \"%s\".\n\ |
| 1054 "), REPORT_BUGS_TO); | 1113 "), REPORT_BUGS_TO); |
| 1055 } | 1114 } |
| OLD | NEW |