1 /* Top level for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
25 #include <sys/param.h>
30 #ifdef SET_STACK_LIMIT_HUGE
32 #include <sys/resource.h>
35 /* Version number of GDB, as a string. */
39 /* Chain containing all defined commands. */
41 struct cmd_list_element
*cmdlist
;
43 /* Chain containing all defined info subcommands. */
45 struct cmd_list_element
*infolist
;
47 /* stdio stream that command input is being read from. */
51 /* Current working directory. */
53 char *current_directory
;
55 /* The directory name is actually stored here. */
56 static char dirbuf
[MAXPATHLEN
];
58 /* Nonzero if we should refrain from using an X window. */
60 int inhibit_windows
= 0;
62 /* Function to call before reading a command, if nonzero.
63 The function receives two args: an input stream,
64 and a prompt string. */
66 void (*window_hook
) ();
68 extern int frame_file_full_name
;
70 void free_command_lines ();
72 static void initialize_main ();
74 static void source_command ();
75 void print_gdb_version ();
77 /* gdb prints this when reading a command interactively */
80 /* Buffer used for reading command lines, and the size
81 allocated for it so far. */
86 /* This is how `error' returns to command level. */
90 return_to_top_level ()
94 clear_breakpoint_commands ();
95 clear_momentary_breakpoints ();
97 longjmp (to_top_level
, 1);
100 main (argc
, argv
, envp
)
105 extern void request_quit ();
107 int inhibit_gdbinit
= 0;
114 line
= (char *) xmalloc (linesize
);
118 current_directory
= dirbuf
;
120 #ifdef SET_STACK_LIMIT_HUGE
124 /* Set the stack limit huge so that alloca (particularly stringtab
125 * in dbxread.c) does not fail. */
126 getrlimit (RLIMIT_STACK
, &rlim
);
127 rlim
.rlim_cur
= rlim
.rlim_max
;
128 setrlimit (RLIMIT_STACK
, &rlim
);
130 #endif /* SET_STACK_LIMIT_HUGE */
132 /* Run the init function of each source file */
134 /* Look for flag arguments. */
136 for (i
= 1; i
< argc
; i
++)
138 if (!strcmp (argv
[i
], "-q") || !strcmp (argv
[i
], "-quiet"))
140 else if (!strcmp (argv
[i
], "-nx"))
142 else if (!strcmp (argv
[i
], "-nw"))
144 else if (!strcmp (argv
[i
], "-fullname"))
145 frame_file_full_name
= 1;
146 else if (!strcmp (argv
[i
], "-batch"))
147 batch
= 1, quiet
= 1;
148 else if (argv
[i
][0] == '-')
152 /* Run the init function of each source file */
154 initialize_all_files ();
155 initialize_main (); /* But that omits this file! Do it now */
157 signal (SIGINT
, request_quit
);
158 signal (SIGQUIT
, SIG_IGN
);
161 print_gdb_version ();
163 /* Process the command line arguments. */
166 for (i
= 1; i
< argc
; i
++)
168 register char *arg
= argv
[i
];
169 /* Args starting with - say what to do with the following arg
173 extern void exec_file_command (), symbol_file_command ();
174 extern void core_file_command (), directory_command ();
175 extern void tty_command ();
177 if (!strcmp (arg
, "-q") || !strcmp (arg
, "-nx")
178 || !strcmp (arg
, "-quiet") || !strcmp (arg
, "-batch")
179 || !strcmp (arg
, "-fullname"))
180 /* Already processed above */
184 fprintf (stderr
, "No argument follows \"%s\".\n", arg
);
185 if (!setjmp (to_top_level
))
187 /* -s foo: get syms from foo. -e foo: execute foo.
188 -se foo: do both with foo. -c foo: use foo as core dump. */
189 if (!strcmp (arg
, "-se"))
191 exec_file_command (argv
[i
], !batch
);
192 symbol_file_command (argv
[i
], !batch
);
194 else if (!strcmp (arg
, "-s") || !strcmp (arg
, "-symbols"))
195 symbol_file_command (argv
[i
], !batch
);
196 else if (!strcmp (arg
, "-e") || !strcmp (arg
, "-exec"))
197 exec_file_command (argv
[i
], !batch
);
198 else if (!strcmp (arg
, "-c") || !strcmp (arg
, "-core"))
199 core_file_command (argv
[i
], !batch
);
200 /* -x foo: execute commands from foo. */
201 else if (!strcmp (arg
, "-x") || !strcmp (arg
, "-command")
202 || !strcmp (arg
, "-commands"))
203 source_command (argv
[i
]);
204 /* -d foo: add directory `foo' to source-file directory
206 else if (!strcmp (arg
, "-d") || !strcmp (arg
, "-dir")
207 || !strcmp (arg
, "-directory"))
208 directory_command (argv
[i
], 0);
209 /* -t /def/ttyp1: use /dev/ttyp1 for inferior I/O. */
210 else if (!strcmp (arg
, "-t") || !strcmp (arg
, "-tty"))
211 tty_command (argv
[i
], 0);
213 error ("Unknown command-line switch: \"%s\"\n", arg
);
218 /* Args not thus accounted for
219 are treated as, first, the symbol/executable file
220 and, second, the core dump file. */
222 if (!setjmp (to_top_level
))
226 exec_file_command (arg
, !batch
);
227 symbol_file_command (arg
, !batch
);
231 core_file_command (arg
, !batch
);
235 fprintf (stderr
, "Excess command line args ignored. (%s%s)\n",
236 arg
, (i
== argc
- 1) ? "" : " ...");
241 /* Read init file, if it exists in home directory */
245 s
= (char *) xmalloc (strlen (getenv ("HOME")) + 10);
246 strcpy (s
, getenv ("HOME"));
247 strcat (s
, "/.gdbinit");
248 if (!inhibit_gdbinit
&& access (s
, R_OK
) == 0)
249 if (!setjmp (to_top_level
))
253 /* Read init file, if it exists in current directory. */
254 if (!inhibit_gdbinit
&& access (".gdbinit", R_OK
) == 0)
255 if (!setjmp (to_top_level
))
256 source_command (".gdbinit");
259 fatal ("Attempt to read commands from stdin in batch mode.");
262 printf ("Type \"help\" for a list of commands.\n");
264 /* The command loop. */
268 if (!setjmp (to_top_level
))
270 clearerr (stdin
); /* Don't get hung if C-d is typed. */
274 /* Execute the line P as a command.
275 Pass FROM_TTY as second argument to the defining function. */
278 execute_command (p
, from_tty
)
282 register struct cmd_list_element
*c
;
283 register struct command_line
*cmdlines
;
286 while (*p
== ' ' || *p
== '\t') p
++;
289 c
= lookup_cmd (&p
, cmdlist
, "", 0);
290 if (c
->function
== 0)
291 error ("That is not a command, just a help topic.");
292 else if (c
->class == (int) class_user
)
295 error ("User-defined commands cannot take command-line arguments: \"%s\"",
297 cmdlines
= (struct command_line
*) c
->function
;
298 if (cmdlines
== (struct command_line
*) 0)
303 execute_command (cmdlines
->line
, 0);
304 cmdlines
= cmdlines
->next
;
308 /* Pass null arg rather than an empty one. */
309 (*c
->function
) (*p
? p
: 0, from_tty
);
318 /* Read commands from `instream' and execute them
319 until end of file. */
323 struct cleanup
*old_chain
;
324 while (!feof (instream
))
326 if (instream
== stdin
)
327 printf ("%s", prompt
);
330 if (window_hook
&& instream
== stdin
)
331 (*window_hook
) (instream
, prompt
);
334 old_chain
= make_cleanup (do_nothing
, 0);
335 execute_command (read_line (instream
== stdin
), instream
== stdin
);
336 /* Do any commands attached to breakpoint we stopped at. */
337 do_breakpoint_commands ();
338 do_cleanups (old_chain
);
345 signal (SIGTSTP
, SIG_DFL
);
347 kill (getpid (), SIGTSTP
);
348 signal (SIGTSTP
, stop_sig
);
349 printf ("%s", prompt
);
352 /* Forget about any previous command -- null line now will do nothing. */
356 /* Commands call this if they do not want to be repeated by null lines. */
364 /* Read one line from the command input stream `instream'
365 into the buffer `line' (whose current length is `linesize').
366 The buffer is made bigger as necessary.
367 Returns the address of the start of the line. */
373 register char *p
= line
;
378 /* Control-C quits instantly if typed while in this loop
379 since it should not wait until the user types a newline. */
381 signal (SIGTSTP
, stop_sig
);
385 c
= fgetc (instream
);
386 if (c
== -1 || c
== '\n')
389 if ((c
= fgetc (instream
)) == '\n')
391 else ungetc (c
, instream
);
392 if (p
- line
== linesize
- 1)
395 nline
= (char *) xrealloc (line
, linesize
);
401 signal (SIGTSTP
, SIG_DFL
);
404 /* If we just got an empty line, and that is supposed
405 to repeat the previous command, leave the last input unchanged. */
406 if (p
== line
&& repeat
)
409 /* If line is a comment, clear it out. */
411 while ((c
= *p1
) == ' ' || c
== '\t') p1
++;
420 /* Read lines from the input stream
421 and accumulate them in a chain of struct command_line's
422 which is then returned. */
424 struct command_line
*
425 read_command_lines ()
427 struct command_line
*first
= 0;
428 register struct command_line
*next
, *tail
= 0;
429 register char *p
, *p1
;
430 struct cleanup
*old_chain
= 0;
436 /* Remove leading and trailing blanks. */
437 while (*p
== ' ' || *p
== '\t') p
++;
439 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
442 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
445 /* No => add this line to the chain of command lines. */
446 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
447 next
->line
= savestring (p
, p1
- p
);
455 /* We just read the first line.
456 From now on, arrange to throw away the lines we have
457 if we quit or get an error while inside this function. */
459 old_chain
= make_cleanup (free_command_lines
, &first
);
466 /* Now we are about to return the chain to our caller,
467 so freeing it becomes his responsibility. */
469 discard_cleanups (old_chain
);
473 /* Free a chain of struct command_line's. */
476 free_command_lines (lptr
)
477 struct command_line
**lptr
;
479 register struct command_line
*l
= *lptr
;
480 register struct command_line
*next
;
491 /* Add an element to the list of info subcommands. */
494 add_info (name
, fun
, doc
)
499 add_cmd (name
, 0, fun
, doc
, &infolist
);
502 /* Add an alias to the list of info subcommands. */
505 add_info_alias (name
, oldname
, abbrev_flag
)
510 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
513 /* The "info" command is defined as a prefix, with allow_unknown = 0.
514 Therefore, its own definition is called only for "info" with no args. */
519 printf ("\"info\" must be followed by the name of an info command.\n");
520 help_cmd (0, infolist
, "info ", -1, stdout
);
523 /* Add an element to the list of commands. */
526 add_com (name
, class, fun
, doc
)
532 add_cmd (name
, class, fun
, doc
, &cmdlist
);
535 /* Add an alias or abbreviation command to the list of commands. */
538 add_com_alias (name
, oldname
, class, abbrev_flag
)
544 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
551 error ("Argument required (%s).", why
);
555 help_command (command
, from_tty
)
557 int from_tty
; /* Ignored */
559 help_cmd (command
, cmdlist
, "", -2, stdout
);
563 validate_comname (comname
)
569 error_no_arg ("name of command to define");
574 if (!(*p
>= 'A' && *p
<= 'Z')
575 && !(*p
>= 'a' && *p
<= 'z')
576 && !(*p
>= '1' && *p
<= '9')
578 error ("Junk in argument list: \"%s\"", p
);
584 define_command (comname
, from_tty
)
588 register struct command_line
*cmds
;
589 register struct cmd_list_element
*c
;
592 validate_comname (comname
);
594 c
= lookup_cmd (&tem
, cmdlist
, "", -1);
597 if (c
->class == (int) class_user
|| c
->class == (int) class_alias
)
598 tem
= "Redefine command \"%s\"? ";
600 tem
= "Really redefine built-in command \"%s\"? ";
601 if (!query (tem
, comname
))
602 error ("Command \"%s\" not redefined.", comname
);
606 printf ("Type commands for definition of \"%s\".\n\
607 End with a line saying just \"end\".\n", comname
);
609 comname
= savestring (comname
, strlen (comname
));
611 cmds
= read_command_lines ();
613 if (c
&& c
->class == (int) class_user
)
614 free_command_lines (&c
->function
);
616 add_com (comname
, class_user
, cmds
,
617 (c
&& c
->class == (int) class_user
)
618 ? c
->doc
: savestring ("User-defined.", 13));
622 document_command (comname
, from_tty
)
626 struct command_line
*doclines
;
627 register struct cmd_list_element
*c
;
630 validate_comname (comname
);
632 c
= lookup_cmd (&tem
, cmdlist
, "", 0);
634 if (c
->class != (int) class_user
)
635 error ("Command \"%s\" is built-in.", comname
);
638 printf ("Type documentation for \"%s\".\n\
639 End with a line saying just \"end\".\n", comname
);
641 doclines
= read_command_lines ();
643 if (c
->doc
) free (c
->doc
);
646 register struct command_line
*cl1
;
647 register int len
= 0;
649 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
650 len
+= strlen (cl1
->line
) + 1;
652 c
->doc
= (char *) xmalloc (len
+ 1);
655 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
657 strcat (c
->doc
, cl1
->line
);
659 strcat (c
->doc
, "\n");
663 free_command_lines (&doclines
);
670 printf (" GDB GENERAL PUBLIC LICENSE\n\
671 \n (Clarified 11 Feb 1988)\
673 Copyright (C) 1988 Richard M. Stallman\n\
674 Everyone is permitted to copy and distribute verbatim copies\n\
675 of this license, but changing it is not allowed.\n\
676 You can also use this wording to make the terms for other programs.\n\
678 The license agreements of most software companies keep you at the\n\
679 mercy of those companies. By contrast, our general public license is\n\
680 intended to give everyone the right to share GDB. To make sure that\n\
681 you get the rights we want you to have, we need to make restrictions\n\
682 that forbid anyone to deny you these rights or to ask you to surrender\n\
683 the rights. Hence this license agreement.\n\
685 Specifically, we want to make sure that you have the right to give\n\
686 away copies of GDB, that you receive source code or else can get it\n\
687 if you want it, that you can change GDB or use pieces of it in new\n\
688 free programs, and that you know you can do these things.\n\
689 --Type Return to print more--");
694 To make sure that everyone has such rights, we have to forbid you to\n\
695 deprive anyone else of these rights. For example, if you distribute\n\
696 copies of GDB, you must give the recipients all the rights that you\n\
697 have. You must make sure that they, too, receive or can get the\n\
698 source code. And you must tell them their rights.\n\
700 Also, for our own protection, we must make certain that everyone\n\
701 finds out that there is no warranty for GDB. If GDB is modified by\n\
702 someone else and passed on, we want its recipients to know that what\n\
703 they have is not what we distributed, so that any problems introduced\n\
704 by others will not reflect on our reputation.\n\
706 Therefore we (Richard Stallman and the Free Software Foundation,\n\
707 Inc.) make the following terms which say what you must do to be\n\
708 allowed to distribute or change GDB.\n\
709 --Type Return to print more--");
716 1. You may copy and distribute verbatim copies of GDB source code as\n\
717 you receive it, in any medium, provided that you conspicuously and\n\
718 appropriately publish on each copy a valid copyright notice \"Copyright\n\
719 \(C) 1988 Free Software Foundation, Inc.\" (or with whatever year is\n\
720 appropriate); keep intact the notices on all files that refer\n\
721 to this License Agreement and to the absence of any warranty; and give\n\
722 any other recipients of the GDB program a copy of this License\n\
723 Agreement along with the program. You may charge a distribution fee\n\
724 for the physical act of transferring a copy.\n\
726 2. You may modify your copy or copies of GDB or any portion of it,\n\
727 and copy and distribute such modifications under the terms of\n\
728 Paragraph 1 above, provided that you also do the following:\n\
730 a) cause the modified files to carry prominent notices stating\n\
731 that you changed the files and the date of any change; and\n\
732 --Type Return to print more--");
737 b) cause the whole of any work that you distribute or publish,\n\
738 that in whole or in part contains or is a derivative of GDB\n\
739 or any part thereof, to be licensed to all third parties on terms\n\
740 identical to those contained in this License Agreement (except that\n\
741 you may choose to grant more extensive warranty protection to some\n\
742 or all third parties, at your option).\n\
745 c) if the modified program serves as a debugger, cause it\n\
746 when started running in the simplest and usual way, to print\n\
747 an announcement including a valid copyright notice\n\
748 \"Copyright (C) 1988 Free Software Foundation, Inc.\" (or with\n\
749 the year that is appropriate), saying that there is no warranty\n\
750 (or else, saying that you provide a warranty) and that users may\n\
751 redistribute the program under these conditions, and telling the user\n\
752 how to view a copy of this License Agreement.\n\
754 d) You may charge a distribution fee for the physical act of\n\
755 transferring a copy, and you may at your option offer warranty\n\
756 protection in exchange for a fee.\n\
758 Mere aggregation of another unrelated program with this program (or its\n\
759 derivative) on a volume of a storage or distribution medium does not bring\n\
760 the other program under the scope of these terms.\n\
761 --Type Return to print more--");
766 3. You may copy and distribute GDB (or a portion or derivative of it,\n\
767 under Paragraph 2) in object code or executable form under the terms of\n\
768 Paragraphs 1 and 2 above provided that you also do one of the following:\n\
770 a) accompany it with the complete corresponding machine-readable\n\
771 source code, which must be distributed under the terms of\n\
772 Paragraphs 1 and 2 above; or,\n\
774 b) accompany it with a written offer, valid for at least three\n\
775 years, to give any third party free (except for a nominal\n\
776 shipping charge) a complete machine-readable copy of the\n\
777 corresponding source code, to be distributed under the terms of\n\
778 Paragraphs 1 and 2 above; or,\n\n");
781 c) accompany it with the information you received as to where the\n\
782 corresponding source code may be obtained. (This alternative is\n\
783 allowed only for noncommercial distribution and only if you\n\
784 received the program in object code or executable form alone.)\n\
786 For an executable file, complete source code means all the source code for\n\
787 all modules it contains; but, as a special exception, it need not include\n\
788 source code for modules which are standard libraries that accompany the\n\
789 operating system on which the executable file runs.\n\
790 --Type Return to print more--");
795 4. You may not copy, sublicense, distribute or transfer GDB\n\
796 except as expressly provided under this License Agreement. Any attempt\n\
797 otherwise to copy, sublicense, distribute or transfer GDB is void and\n\
798 your rights to use the program under this License agreement shall be\n\
799 automatically terminated. However, parties who have received computer\n\
800 software programs from you with this License Agreement will not have\n\
801 their licenses terminated so long as such parties remain in full compliance.\n\
803 5. If you wish to incorporate parts of GDB into other free\n\
804 programs whose distribution conditions are different, write to the Free\n\
805 Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet\n\
806 worked out a simple rule that can be stated here, but we will often permit\n\
807 this. We will be guided by the two goals of preserving the free status of\n\
808 all derivatives of our free software and of promoting the sharing and reuse\n\
811 In other words, go ahead and share GDB, but don't try to stop\n\
812 anyone else from sharing it farther. Help stamp out software hoarding!\n\
821 printf (" NO WARRANTY\n\
823 BECAUSE GDB IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO\n\
824 WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT\n\
825 WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,\n\
826 RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GDB \"AS IS\" WITHOUT\n\
827 WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT\n\
828 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\
829 A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND\n\
830 PERFORMANCE OF GDB IS WITH YOU. SHOULD GDB PROVE DEFECTIVE, YOU\n\
831 ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n");
834 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.\n\
835 STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY\n\
836 WHO MAY MODIFY AND REDISTRIBUTE GDB, BE LIABLE TO\n\
837 YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER\n\
838 SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR\n\
839 INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA\n\
840 BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A\n\
841 FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GDB, EVEN\n\
842 IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR\n\
843 ANY CLAIM BY ANY OTHER PARTY.\n");
850 printf ("GDB %s, Copyright (C) 1988 Free Software Foundation, Inc.\n\
851 There is ABSOLUTELY NO WARRANTY for GDB; type \"info warranty\" for details.\n\
852 GDB is free software and you are welcome to distribute copies of it\n\
853 under certain conditions; type \"info copying\" to see the conditions.\n",
861 print_gdb_version ();
866 set_prompt_command (text
)
874 error_no_arg ("string to which to set prompt");
876 new = (char *) xmalloc (strlen (text
) + 2);
882 /* \ at end of argument is used after spaces
883 so they won't be lost. */
886 c
= parse_escape (&p
);
895 if (*(p
- 1) != '\\')
898 new = (char *) xrealloc (new, q
- new);
906 if (have_inferior_p ())
908 if (query ("The program is running. Quit anyway? "))
910 /* Prevent any warning message from reopen_exec_file, in case
911 we have a core file that's inconsistent with the exec file. */
912 exec_file_command (0, 0);
916 error ("Not confirmed.");
922 input_from_terminal_p ()
924 return instream
== stdin
;
928 pwd_command (arg
, from_tty
)
932 if (arg
) error ("The \"pwd\" command does not take an argument: %s", arg
);
933 printf ("Working directory %s.\n", dirbuf
);
937 cd_command (dir
, from_tty
)
942 error_no_arg ("new working directory");
945 perror_with_name (dir
);
948 pwd_command ((char *) 0, 1);
952 /* Clean up on error during a "source" command.
953 Close the file opened by the command
954 and restore the previous input stream. */
957 source_cleanup (stream
)
965 source_command (file
)
969 struct cleanup
*cleanups
;
972 error_no_arg ("file to read commands from");
974 stream
= fopen (file
, "r");
976 perror_with_name (file
);
978 cleanups
= make_cleanup (source_cleanup
, instream
);
984 do_cleanups (cleanups
);
999 /* \ at end of argument is used after spaces
1000 so they won't be lost. */
1004 c
= parse_escape (&p
);
1016 if (query ("Should GDB dump core? "))
1018 signal (SIGQUIT
, SIG_DFL
);
1019 kill (getpid (), SIGQUIT
);
1027 prompt
= savestring ("(gdb+) ", 7);
1029 /* Define the classes of commands.
1030 They will appear in the help list in the reverse of this order. */
1032 add_cmd ("obscure", class_obscure
, 0, "Obscure features.", &cmdlist
);
1033 add_cmd ("alias", class_alias
, 0, "Aliases of other commands.", &cmdlist
);
1034 add_cmd ("user", class_user
, 0, "User-defined commands.\n\
1035 The commands in this class are those defined by the user.\n\
1036 Use the \"define\" command to define a command.", &cmdlist
);
1037 add_cmd ("support", class_support
, 0, "Support facilities.", &cmdlist
);
1038 add_cmd ("status", class_info
, 0, "Status inquiries.", &cmdlist
);
1039 add_cmd ("files", class_files
, 0, "Specifying and examining files.", &cmdlist
);
1040 add_cmd ("breakpoints", class_breakpoint
, 0, "Making program stop at certain points.", &cmdlist
);
1041 add_cmd ("data", class_vars
, 0, "Examining data.", &cmdlist
);
1042 add_cmd ("stack", class_stack
, 0, "Examining the stack.\n\
1043 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
1044 counting from zero for the innermost (currently executing) frame.\n\n\
1045 At any time gdb identifies one frame as the \"selected\" frame.\n\
1046 Variable lookups are done with respect to the selected frame.\n\
1047 When the program being debugged stops, gdb selects the innermost frame.\n\
1048 The commands below can be used to select other frames by number or address.",
1050 add_cmd ("running", class_run
, 0, "Running the program.", &cmdlist
);
1052 add_com ("pwd", class_files
, pwd_command
,
1053 "Print working directory. This is used for your program as well.");
1054 add_com ("cd", class_files
, cd_command
,
1055 "Set working directory to DIR for debugger and program being debugged.\n\
1056 The change does not take effect for the program being debugged\n\
1057 until the next time it is started.");
1059 add_com ("set-prompt", class_support
, set_prompt_command
,
1060 "Change gdb's prompt from the default of \"(gdb)\"");
1061 add_com ("echo", class_support
, echo_command
,
1062 "Print a constant string. Give string as argument.\n\
1063 C escape sequences may be used in the argument.\n\
1064 No newline is added at the end of the argument;\n\
1065 use \"\\n\" if you want a newline to be printed.\n\
1066 Since leading and trailing whitespace are ignored in command arguments,\n\
1067 if you want to print some you must use \"\\\" before leading whitespace\n\
1068 to be printed or after trailing whitespace.");
1069 add_com ("document", class_support
, document_command
,
1070 "Document a user-defined command.\n\
1071 Give command name as argument. Give documentation on following lines.\n\
1072 End with a line of just \"end\".");
1073 add_com ("define", class_support
, define_command
,
1074 "Define a new command name. Command name is argument.\n\
1075 Definition appears on following lines, one command per line.\n\
1076 End with a line of just \"end\".\n\
1077 Use the \"document\" command to give documentation for the new command.\n\
1078 Commands defined in this way do not take arguments.");
1080 add_com ("source", class_support
, source_command
,
1081 "Read commands from a file named FILE.\n\
1082 Note that the file \".gdbinit\" is read automatically in this way\n\
1083 when gdb is started.");
1084 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
1085 add_com ("help", class_support
, help_command
, "Print list of commands.");
1086 add_com_alias ("q", "quit", class_support
, 1);
1087 add_com_alias ("h", "help", class_support
, 1);
1089 add_com ("dump-me", class_obscure
, dump_me_command
,
1090 "Get fatal error; make debugger dump its core.");
1092 add_prefix_cmd ("info", class_info
, info_command
,
1093 "Generic command for printing status.",
1094 &infolist
, "info ", 0, &cmdlist
);
1095 add_com_alias ("i", "info", class_info
, 1);
1097 add_info ("copying", copying_info
, "Conditions for redistributing copies of GDB.");
1098 add_info ("warranty", warranty_info
, "Various kinds of warranty you do not have.");
1099 add_info ("version", version_info
, "Report what version of GDB this is.");
This page took 0.051334 seconds and 5 git commands to generate.