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

📄 cli-cmds.c

📁 这个是LINUX下的GDB调度工具的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
  else if (!(space_index = (char *) strchr (arg, ' ')))    {      /* One argument.  */      pc = parse_and_eval_address (arg);      if (find_pc_partial_function (pc, &name, &low, &high) == 0)	error ("No function contains specified address.\n");#if defined(TUI)      /* NOTE: cagney/2003-02-13 The `tui_active' was previously	 `tui_version'.  */      if (tui_active)	/* FIXME: cagney/2004-02-07: This should be an observer.  */	low = tui_get_low_disassembly_address (low, pc);#endif      low += DEPRECATED_FUNCTION_START_OFFSET;    }  else    {      /* Two arguments.  */      *space_index = '\0';      low = parse_and_eval_address (arg);      high = parse_and_eval_address (space_index + 1);    }#if defined(TUI)  if (!tui_is_window_visible (DISASSEM_WIN))#endif    {      printf_filtered ("Dump of assembler code ");      if (name != NULL)	{	  printf_filtered ("for function %s:\n", name);	}      else	{	  printf_filtered ("from ");	  print_address_numeric (low, 1, gdb_stdout);	  printf_filtered (" to ");	  print_address_numeric (high, 1, gdb_stdout);	  printf_filtered (":\n");	}      /* Dump the specified range.  */      gdb_disassembly (uiout, 0, 0, 0, -1, low, high);      printf_filtered ("End of assembler dump.\n");      gdb_flush (gdb_stdout);    }#if defined(TUI)  else    {      tui_show_assembly (low);    }#endif}static voidmake_command (char *arg, int from_tty){  char *p;  if (arg == 0)    p = "make";  else    {      p = xmalloc (sizeof ("make ") + strlen (arg));      strcpy (p, "make ");      strcpy (p + sizeof ("make ") - 1, arg);    }  shell_escape (p, from_tty);}static voidshow_user (char *args, int from_tty){  struct cmd_list_element *c;  extern struct cmd_list_element *cmdlist;  if (args)    {      c = lookup_cmd (&args, cmdlist, "", 0, 1);      if (c->class != class_user)	error ("Not a user command.");      show_user_1 (c, gdb_stdout);    }  else    {      for (c = cmdlist; c; c = c->next)	{	  if (c->class == class_user)	    show_user_1 (c, gdb_stdout);	}    }}/* Search through names of commands and documentations for a certain   regular expression.*/void apropos_command (char *searchstr, int from_tty){  extern struct cmd_list_element *cmdlist; /*This is the main command list*/  regex_t pattern;  char *pattern_fastmap;  char errorbuffer[512];  pattern_fastmap = xcalloc (256, sizeof (char));  if (searchstr == NULL)      error("REGEXP string is empty");  if (regcomp(&pattern,searchstr,REG_ICASE) == 0)    {      pattern.fastmap=pattern_fastmap;      re_compile_fastmap(&pattern);      apropos_cmd (gdb_stdout,cmdlist,&pattern,"");    }  else    {      regerror(regcomp(&pattern,searchstr,REG_ICASE),NULL,errorbuffer,512);      error("Error in regular expression:%s",errorbuffer);    }  xfree (pattern_fastmap);}/* Print a list of files and line numbers which a user may choose from   in order to list a function which was specified ambiguously (as with   `list classname::overloadedfuncname', for example).  The vector in   SALS provides the filenames and line numbers.  */static voidambiguous_line_spec (struct symtabs_and_lines *sals){  int i;  for (i = 0; i < sals->nelts; ++i)    printf_filtered ("file: \"%s\", line number: %d\n",		     sals->sals[i].symtab->filename, sals->sals[i].line);}static voidset_debug (char *arg, int from_tty){  printf_unfiltered ("\"set debug\" must be followed by the name of a print subcommand.\n");  help_list (setdebuglist, "set debug ", -1, gdb_stdout);}static voidshow_debug (char *args, int from_tty){  cmd_show_list (showdebuglist, from_tty, "");}voidinit_cmd_lists (void){  max_user_call_depth = 1024;  cmdlist = NULL;  infolist = NULL;  enablelist = NULL;  disablelist = NULL;  togglelist = NULL;  stoplist = NULL;  deletelist = NULL;  enablebreaklist = NULL;  setlist = NULL;  unsetlist = NULL;  showlist = NULL;  sethistlist = NULL;  showhistlist = NULL;  unsethistlist = NULL;  maintenancelist = NULL;  maintenanceinfolist = NULL;  maintenanceprintlist = NULL;  setprintlist = NULL;  showprintlist = NULL;  setchecklist = NULL;  showchecklist = NULL;}voidinit_cli_cmds (void){  struct cmd_list_element *c;  /* Define the classes of commands.     They will appear in the help list in the reverse of this order.  */  add_cmd ("internals", class_maintenance, NULL,	   "Maintenance commands.\n\Some gdb commands are provided just for use by gdb maintainers.\n\These commands are subject to frequent change, and may not be as\n\well documented as user commands.",	   &cmdlist);  add_cmd ("obscure", class_obscure, NULL, "Obscure features.", &cmdlist);  add_cmd ("aliases", class_alias, NULL, "Aliases of other commands.", &cmdlist);  add_cmd ("user-defined", class_user, NULL, "User-defined commands.\n\The commands in this class are those defined by the user.\n\Use the \"define\" command to define a command.", &cmdlist);  add_cmd ("support", class_support, NULL, "Support facilities.", &cmdlist);  if (!dbx_commands)    add_cmd ("status", class_info, NULL, "Status inquiries.", &cmdlist);  add_cmd ("files", class_files, NULL, "Specifying and examining files.", &cmdlist);  add_cmd ("breakpoints", class_breakpoint, NULL, "Making program stop at certain points.", &cmdlist);  add_cmd ("data", class_vars, NULL, "Examining data.", &cmdlist);  add_cmd ("stack", class_stack, NULL, "Examining the stack.\n\The stack is made up of stack frames.  Gdb assigns numbers to stack frames\n\counting from zero for the innermost (currently executing) frame.\n\n\At any time gdb identifies one frame as the \"selected\" frame.\n\Variable lookups are done with respect to the selected frame.\n\When the program being debugged stops, gdb selects the innermost frame.\n\The commands below can be used to select other frames by number or address.",	   &cmdlist);  add_cmd ("running", class_run, NULL, "Running the program.", &cmdlist);  /* Define general commands. */  add_com ("pwd", class_files, pwd_command,	"Print working directory.  This is used for your program as well.");  c = add_cmd ("cd", class_files, cd_command,	       "Set working directory to DIR for debugger and program being debugged.\n\The change does not take effect for the program being debugged\n\until the next time it is started.", &cmdlist);  set_cmd_completer (c, filename_completer);  add_com ("echo", class_support, echo_command,	   "Print a constant string.  Give string as argument.\n\C escape sequences may be used in the argument.\n\No newline is added at the end of the argument;\n\use \"\\n\" if you want a newline to be printed.\n\Since leading and trailing whitespace are ignored in command arguments,\n\if you want to print some you must use \"\\\" before leading whitespace\n\to be printed or after trailing whitespace.");  add_com ("document", class_support, document_command,	   "Document a user-defined command.\n\Give command name as argument.  Give documentation on following lines.\n\End with a line of just \"end\".");  add_com ("define", class_support, define_command,	   "Define a new command name.  Command name is argument.\n\Definition appears on following lines, one command per line.\n\End with a line of just \"end\".\n\Use the \"document\" command to give documentation for the new command.\n\Commands defined in this way may have up to ten arguments.");  c = add_cmd ("source", class_support, source_command,	       "Read commands from a file named FILE.\n\Note that the file \"" GDBINIT_FILENAME "\" is read automatically in this way\n\when gdb is started.", &cmdlist);  set_cmd_completer (c, filename_completer);  add_com ("quit", class_support, quit_command, "Exit gdb.");  c = add_com ("help", class_support, help_command, "Print list of commands.");  set_cmd_completer (c, command_completer);  add_com_alias ("q", "quit", class_support, 1);  add_com_alias ("h", "help", class_support, 1);  c = add_set_cmd ("verbose", class_support, var_boolean, (char *) &info_verbose,		   "Set ",		   &setlist),    deprecated_add_show_from_set (c, &showlist);  set_cmd_sfunc (c, set_verbose);  set_verbose (NULL, 0, c);  add_prefix_cmd ("history", class_support, set_history,		  "Generic command for setting command history parameters.",		  &sethistlist, "set history ", 0, &setlist);  add_prefix_cmd ("history", class_support, show_history,		  "Generic command for showing command history parameters.",		  &showhistlist, "show history ", 0, &showlist);  deprecated_add_show_from_set    (add_set_cmd ("expansion", no_class, var_boolean, (char *) &history_expansion_p,		  "Set history expansion on command input.\n\Without an argument, history expansion is enabled.", &sethistlist),     &showhistlist);  add_prefix_cmd ("info", class_info, info_command,     "Generic command for showing things about the program being debugged.",		  &infolist, "info ", 0, &cmdlist);  add_com_alias ("i", "info", class_info, 1);  add_com ("complete", class_obscure, complete_command,	   "List the completions for the rest of the line as a command.");  add_prefix_cmd ("show", class_info, show_command,		  "Generic command for showing things about the debugger.",		  &showlist, "show ", 0, &cmdlist);  /* Another way to get at the same thing.  */  add_info ("set", show_command, "Show all GDB settings.");  add_cmd ("commands", no_class, show_commands,	   "Show the history of commands you typed.\n\You can supply a command number to start with, or a `+' to start after\n\the previous command number shown.",	   &showlist);  add_cmd ("version", no_class, show_version,	   "Show what version of GDB this is.", &showlist);  add_com ("while", class_support, while_command,	   "Execute nested commands WHILE the conditional expression is non zero.\n\The conditional expression must follow the word `while' and must in turn be\n\followed by a new line.  The nested commands must be entered one per line,\n\and should be terminated by the word `end'.");  add_com ("if", class_support, if_command,	   "Execute nested commands once IF the conditional expression is non zero.\n\The conditional expression must follow the word `if' and must in turn be\n\followed by a new line.  The nested commands must be entered one per line,\n\and should be terminated by the word 'else' or `end'.  If an else clause\n\is used, the same rules apply to its nested commands as to the first ones.");  /* If target is open when baud changes, it doesn't take effect until the     next open (I think, not sure).  */  deprecated_add_show_from_set    (add_set_cmd ("remotebaud", no_class,		  var_zinteger, (char *) &baud_rate,		  "Set baud rate for remote serial I/O.\n\This value is used to set the speed of the serial port when debugging\n\using remote targets.", &setlist),		     &showlist);  c = add_set_cmd ("remotedebug", no_class, var_zinteger,		   (char *) &remote_debug,		   "Set debugging of remote protocol.\n\When enabled, each packet sent or received with the remote target\n\is displayed.", &setlist);  deprecate_cmd (c, "set debug remote");  deprecate_cmd (deprecated_add_show_from_set (c, &showlist),		 "show debug remote");  deprecated_add_show_from_set    (add_set_cmd ("remote", no_class, var_zinteger,		  (char *) &remote_debug,		  "Set debugging of remote protocol.\n\When enabled, each packet sent or received with the remote target\n\is displayed.", &setdebuglist),		     &showdebuglist);  deprecated_add_show_from_set    (add_set_cmd ("remotetimeout", no_class, var_integer, (char *) &remote_timeout,		  "Set timeout limit to wait for target to respond.\n\This value is used to set the time limit for gdb to wait for a response\n\from the target.", &setlist),     &showlist);  add_prefix_cmd ("debug", no_class, set_debug,		  "Generic command for setting gdb debugging flags",		  &setdebuglist, "set debug ", 0, &setlist);  add_prefix_cmd ("debug", no_class, show_debug,		  "Generic command for showing gdb debugging flags",		  &showdebuglist, "show debug ", 0, &showlist);  c = add_com ("shell", class_support, shell_escape,	       "Execute the rest of the line as a shell command.\n\With no arguments, run an inferior shell.");  set_cmd_completer (c, filename_completer);  c = add_com ("edit", class_files, edit_command,           concat ("Edit specified file or function.\n\With no argument, edits file containing most recent line listed.\n\", "\Editing targets can be specified in these ways:\n\  FILE:LINENUM, to edit at that line in that file,\n\  FUNCTION, to edit at the beginning of that function,\n\  FILE:FUNCTION, to distinguish among like-named static functions.\n\  *ADDRESS, to edit at the line containing that address.\n\Uses EDITOR environment variable contents as editor (or ex as default).",NULL));  c->completer = location_completer;  add_com ("list", class_files, list_command,	   concat ("List specified function or line.\n\With no argument, lists ten more lines after or around previous listing.\n\\"list -\" lists the ten lines before a previous ten-line listing.\n\One argument specifies a line, and ten lines are listed around that line.\n\Two arguments with comma between specify starting and ending lines to list.\n\", "\Lines can be specified in these ways:\n\  LINENUM, to list around that line in current file,\n\  FILE:LINENUM, to list around that line in that file,\n\  FUNCTION, to list around beginning of that function,\n\  FILE:FUNCTION, to distinguish among like-named static functions.\n\  *ADDRESS, to list around the line containing that address.\n\With two args if one is empty it stands for ten lines away from the other arg.", NULL));  if (!xdb_commands)    add_com_alias ("l", "list", class_files, 1);  else    add_com_alias ("v", "list", class_files, 1);  if (dbx_commands)    add_com_alias ("file", "list", class_files, 1);  c = add_com ("disassemble", class_vars, disassemble_command,	       "Disassemble a specified section of memory.\n\Default is the function surrounding the pc of the selected frame.\n\With a single argument, the function surrounding that address is dumped.\n\Two arguments are taken as a range of memory to dump.");  set_cmd_completer (c, location_completer);  if (xdb_commands)    add_com_alias ("va", "disassemble", class_xdb, 0);  /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would     be a really useful feature.  Unfortunately, the below wont do     this.  Instead it adds support for the form ``(gdb) ! ls''     (i.e. the space is required).  If the ``!'' command below is     added the complains about no ``!'' command would be replaced by     complains about how the ``!'' command is broken :-) */  if (xdb_commands)    add_com_alias ("!", "shell", class_support, 0);  c = add_com ("make", class_support, make_command,          "Run the ``make'' program using the rest of the line as arguments.");  set_cmd_completer (c, filename_completer);  add_cmd ("user", no_class, show_user,	   "Show definitions of user defined commands.\n\Argument is the name of the user defined command.\n\With no argument, show definitions of all user defined commands.", &showlist);  add_com ("apropos", class_support, apropos_command, "Search for commands matching a REGEXP");  deprecated_add_show_from_set    (add_set_cmd ("max-user-call-depth", no_class, var_integer, 		  (char *) &max_user_call_depth,		  "Set the max call depth for user-defined commands.\n", 		  &setlist),     &showlist);}

⌨️ 快捷键说明

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