⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Top level `main' program for GDB, the GNU debugger.   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992   Free Software Foundation, Inc.This file is part of GDB.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */#include <stdio.h>#include <sys/param.h>int fclose ();#include "defs.h"#include "gdbcmd.h"#include "call-cmds.h"#include "gdbcore.h"#include "symtab.h"#include "inferior.h"#include "signals.h"#include "target.h"#include "breakpoint.h"#include "gdbtypes.h"#include "expression.h"#include "language.h"#include "getopt.h"/* readline include files */#include "readline.h"#include "history.h"/* readline defines these.  */#undef savestring#undef CTRL#ifdef USG#include <sys/types.h>#include <unistd.h>#endif#include <string.h>#ifndef	NO_SYS_FILE#include <sys/file.h>#endif#include <setjmp.h>#include <sys/stat.h>#include <ctype.h>#ifdef SET_STACK_LIMIT_HUGE#include <sys/time.h>#include <sys/resource.h>int original_stack_limit;#endif/* Prototypes for local functions */static char *symbol_completion_function PARAMS ((char *, int));static voidcommand_loop PARAMS ((void));static voidcommand_loop_marker PARAMS ((int));static voidprint_gdb_version PARAMS ((void));static voidquit_command PARAMS ((char *, int));static voidinitialize_main PARAMS ((void));static voidinitialize_history PARAMS ((void));static voidinitialize_cmd_lists PARAMS ((void));static voidfloat_handler PARAMS ((int));static voidsource_command PARAMS ((char *, int));static voidcd_command PARAMS ((char *, int));static voidprint_gnu_advertisement PARAMS ((void));static voidinit_signals PARAMS ((void));static voidread_command_file PARAMS ((FILE *));static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));static voidshow_history PARAMS ((char *, int));static voidset_history PARAMS ((char *, int));static voidset_history_size_command PARAMS ((char *, int, struct cmd_list_element *));static voidshow_commands PARAMS ((char *, int));static voidecho_command PARAMS ((char *, int));static voidpwd_command PARAMS ((char *, int));static voidshow_version PARAMS ((char *, int));static voiddocument_command PARAMS ((char *, int));static voiddefine_command PARAMS ((char *, int));static voidvalidate_comname PARAMS ((char *));static voidhelp_command PARAMS ((char *, int));static voidshow_command PARAMS ((char *, int));static voidinfo_command PARAMS ((char *, int));static voiddo_nothing PARAMS ((int));static intquit_cover PARAMS ((char *));static voiddisconnect PARAMS ((int));voidsource_cleanup PARAMS ((FILE *));/* If this definition isn't overridden by the header files, assume   that isatty and fileno exist on this system.  */#ifndef ISATTY#define ISATTY(FP)	(isatty (fileno (FP)))#endif/* Initialization file name for gdb.  This is overridden in some configs.  */#ifndef	GDBINIT_FILENAME#define	GDBINIT_FILENAME	".gdbinit"#endifchar gdbinit[] = GDBINIT_FILENAME;#define	ALL_CLEANUPS	((struct cleanup *)0)/* Version number of GDB, as a string.  */extern char *version;/* Message to be printed before the error message, when an error occurs.  */extern char *error_pre_print;/* Message to be printed before the warning message, when a warning occurs.  */extern char *warning_pre_print;extern char lang_frame_mismatch_warn[];		/* language.c *//* Whether GDB's stdin is on a terminal.  */extern int gdb_has_a_terminal;			/* inflow.c *//* Flag for whether we want all the "from_tty" gubbish printed.  */int caution = 1;			/* Default is yes, sigh. *//* * Define all cmd_list_element's *//* Chain containing all defined commands.  */struct cmd_list_element *cmdlist;/* Chain containing all defined info subcommands.  */struct cmd_list_element *infolist;/* Chain containing all defined enable subcommands. */struct cmd_list_element *enablelist;/* Chain containing all defined disable subcommands. */struct cmd_list_element *disablelist;/* Chain containing all defined delete subcommands. */struct cmd_list_element *deletelist;/* Chain containing all defined "enable breakpoint" subcommands. */struct cmd_list_element *enablebreaklist;/* Chain containing all defined set subcommands */struct cmd_list_element *setlist;/* Chain containing all defined unset subcommands */struct cmd_list_element *unsetlist;/* Chain containing all defined show subcommands.  */struct cmd_list_element *showlist;/* Chain containing all defined \"set history\".  */struct cmd_list_element *sethistlist;/* Chain containing all defined \"show history\".  */struct cmd_list_element *showhistlist;/* Chain containing all defined \"unset history\".  */struct cmd_list_element *unsethistlist;/* Chain containing all defined maintenance subcommands. */#if MAINTENANCE_CMDSstruct cmd_list_element *maintenancelist;#endif/* Chain containing all defined "maintenance info" subcommands. */#if MAINTENANCE_CMDSstruct cmd_list_element *maintenanceinfolist;#endif/* Chain containing all defined "maintenance print" subcommands. */#if MAINTENANCE_CMDSstruct cmd_list_element *maintenanceprintlist;#endifstruct cmd_list_element *setprintlist;struct cmd_list_element *showprintlist;struct cmd_list_element *setchecklist;struct cmd_list_element *showchecklist;/* stdio stream that command input is being read from.  */FILE *instream;/* Current working directory.  */char *current_directory;/* The directory name is actually stored here (usually).  */static char dirbuf[MAXPATHLEN];#ifdef KERNELDEBUG/* Nonzero if we're debugging /dev/kmem or a kernel crash dump */int kernel_debugging;#endif/* Function to call before reading a command, if nonzero.   The function receives two args: an input stream,   and a prompt string.  */void (*window_hook) PARAMS ((FILE *, char *));extern int frame_file_full_name;extern int mapped_symbol_files;extern int readnow_symbol_files;/* Nonzero to inhibit confirmation of quitting or restarting   a stopped inferior. */int inhibit_confirm;/* The number of lines on a page */int pagesize;/* Nonzero if we should refrain from using an X window.  */int inhibit_windows = 0;extern int frame_file_full_name;int epoch_interface;int xgdb_verbose;/* Buffer used for reading command lines, and the size   allocated for it so far.  */char *line;int linesize = 100;char *getenv ();/* gdb prints this when reading a command interactively */static char *masterprompt;/* Baud rate specified for talking to serial target systems.  Default   is left as a zero pointer, so targets can choose their own defaults.  */char *baud_rate;/* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT.  */#ifndef STOP_SIGNAL#ifdef SIGTSTP#define STOP_SIGNAL SIGTSTPstatic void stop_sig PARAMS ((int));#endif#endif/* Some System V have job control but not sigsetmask(). */#if !defined (HAVE_SIGSETMASK)#define HAVE_SIGSETMASK !defined (USG)#endif#if 0 == (HAVE_SIGSETMASK)#define sigsetmask(n)#endif/* This is how `error' returns to command level.  */jmp_buf to_top_level;NORETURN voidreturn_to_top_level (){  quit_flag = 0;  immediate_quit = 0;  bpstat_clear_actions(stop_bpstat);	/* Clear queued breakpoint commands */  disable_current_display ();  do_cleanups (ALL_CLEANUPS);  (NORETURN void) longjmp (to_top_level, 1);}/* Call FUNC with arg ARGS, catching any errors.   If there is no error, return the value returned by FUNC.   If there is an error, print ERRSTRING, print the specific error message,		         then return zero.  */intcatch_errors (func, args, errstring)     int (*func) PARAMS ((char *));     char *args;     char *errstring;{  jmp_buf saved;  int val;  struct cleanup *saved_cleanup_chain;  char *saved_error_pre_print;  saved_cleanup_chain = save_cleanups ();  saved_error_pre_print = error_pre_print;  memcpy ((char *)saved, (char *)to_top_level, sizeof (jmp_buf));  error_pre_print = errstring;  if (setjmp (to_top_level) == 0)    val = (*func) (args);  else    val = 0;  restore_cleanups (saved_cleanup_chain);  error_pre_print = saved_error_pre_print;  memcpy ((char *)to_top_level, (char *)saved, sizeof (jmp_buf));  return val;}/* Handler for SIGHUP.  */static voiddisconnect (signo)int signo;{  catch_errors (quit_cover, NULL, "Could not kill inferior process");  signal (SIGHUP, SIG_DFL);  kill (getpid (), SIGHUP);}/* Just a little helper function for disconnect().  */static intquit_cover (s)char *s;{  caution = 0;		/* Throw caution to the wind -- we're exiting.			   This prevents asking the user dumb questions.  */  quit_command((char *)0, 0);  return 0;}/* * Source an init file if it exists. */voidsourcefile(file)	char *file;{	if (access (file, R_OK) == 0)		if (!setjmp (to_top_level))			source_command (file, 0);	do_cleanups(ALL_CLEANUPS);}/* * Source $HOME/.gdbinit and $cwd/.gdbinit. * If X is enabled, also $HOME/.xgdbinit and $cwd/.xgdbinit.source */voidsource_init_files(){	char *homedir, initfile[256];	int samedir = 0;	/* Read init file, if it exists in home directory  */	homedir = getenv ("HOME");	if (homedir) {		struct stat homebuf, cwdbuf;		sprintf(initfile, "%s/%s", homedir, gdbinit);		sourcefile(initfile);		if (!inhibit_windows) {			sprintf(initfile, "%s/.xgdbinit", homedir);			sourcefile(initfile);		}#ifdef KERNELDEBUG		if (kernel_debugging) {			sprintf(initfile, "%s/.kgdbinit", homedir);			sourcefile(initfile);		}#endif		/* Determine if current directory is the same as the home		   directory, so we don't source the same file twice. */			bzero (&homebuf, sizeof (struct stat));		bzero (&cwdbuf, sizeof (struct stat));			stat(homedir, &homebuf);		stat(".", &cwdbuf);				samedir = bcmp(&homebuf, &cwdbuf, sizeof(struct stat)) == 0;	}	/* Read the input file in the current directory, *if* it isn't	   the same file (it should exist, also).  */	if (!samedir) {		sourcefile(gdbinit);		sourcefile(".xgdbinit");#ifdef KERNELDEBUG		if (kernel_debugging) 			sourcefile(".kgdbinit");#endif	}}/* Clean up on error during a "source" command (or execution of a   user-defined command).  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -