X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fcli%2Fcli-cmds.c;h=c60e5efd0cc84c3b1c162710cb079e811e1368ee;hb=081bca4d622143b229cf02a1dda4afb9b457eefa;hp=a1c308a38d202e239f81941bb5ab9911ef162dea;hpb=981a3fb3594dddae266b7a5014c3001727200d7b;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index a1c308a38d..c60e5efd0c 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1,6 +1,6 @@ /* GDB CLI commands. - Copyright (C) 2000-2017 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of GDB. @@ -38,6 +38,7 @@ #include "tracepoint.h" #include "filestuff.h" #include "location.h" +#include "block.h" #include "ui-out.h" @@ -58,24 +59,6 @@ #include #include -/* Prototypes for local command functions */ - -static void complete_command (char *, int); - -static void echo_command (char *, int); - -static void pwd_command (char *, int); - -static void help_command (char *, int); - -static void make_command (char *, int); - -static void shell_escape (const char *, int); - -static void edit_command (char *, int); - -static void list_command (char *, int); - /* Prototypes for local utility functions */ static void print_sal_location (const symtab_and_line &sal); @@ -225,20 +208,12 @@ show_command (const char *arg, int from_tty) cmd_show_list (showlist, from_tty, ""); } -/* A temporary non-const overload of show_command. */ - -static void -show_command (char *arg, int from_tty) -{ - cmd_show_list (showlist, from_tty, ""); -} - /* Provide documentation on command or list given by COMMAND. FROM_TTY is ignored. */ static void -help_command (char *command, int from_tty) +help_command (const char *command, int from_tty) { help_cmd (command, gdb_stdout); } @@ -248,10 +223,8 @@ help_command (char *command, int from_tty) [Is that why this function writes output with *_unfiltered?] */ static void -complete_command (char *arg_entry, int from_tty) +complete_command (const char *arg, int from_tty) { - const char *arg = arg_entry; - dont_repeat (); if (max_completions == 0) @@ -343,7 +316,7 @@ is_complete_command (struct cmd_list_element *c) static void show_version (const char *args, int from_tty) { - print_gdb_version (gdb_stdout); + print_gdb_version (gdb_stdout, true); printf_filtered ("\n"); } @@ -356,7 +329,7 @@ show_configuration (const char *args, int from_tty) /* Handle the quit command. */ void -quit_command (char *args, int from_tty) +quit_command (const char *args, int from_tty) { int exit_code = 0; @@ -378,7 +351,7 @@ quit_command (char *args, int from_tty) } static void -pwd_command (char *args, int from_tty) +pwd_command (const char *args, int from_tty) { if (args) error (_("The \"pwd\" command does not take an argument: %s"), args); @@ -524,7 +497,7 @@ gdb::optional find_and_open_script (const char *script_file, int search_path) { int fd; - int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; + openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; gdb::optional opened; gdb::unique_xmalloc_ptr file (tilde_expand (script_file)); @@ -534,10 +507,9 @@ find_and_open_script (const char *script_file, int search_path) /* Search for and open 'file' on the search path used for source files. Put the full location in *FULL_PATHP. */ - char *temp_path; + gdb::unique_xmalloc_ptr full_path; fd = openp (source_path, search_flags, - file.get (), O_RDONLY, &temp_path); - gdb::unique_xmalloc_ptr full_path (temp_path); + file.get (), O_RDONLY, &full_path); if (fd == -1) return opened; @@ -693,7 +665,7 @@ source_command (const char *args, int from_tty) static void -echo_command (char *text, int from_tty) +echo_command (const char *text, int from_tty) { const char *p = text; int c; @@ -758,7 +730,7 @@ shell_escape (const char *arg, int from_tty) close_most_fds (); - if ((user_shell = (char *) getenv ("SHELL")) == NULL) + if ((user_shell = getenv ("SHELL")) == NULL) user_shell = "/bin/sh"; /* Get the name of the shell for arg0. */ @@ -785,13 +757,13 @@ shell_escape (const char *arg, int from_tty) /* Implementation of the "shell" command. */ static void -shell_command (char *arg, int from_tty) +shell_command (const char *arg, int from_tty) { shell_escape (arg, from_tty); } static void -edit_command (char *arg, int from_tty) +edit_command (const char *arg, int from_tty) { struct symtab_and_line sal; struct symbol *sym; @@ -878,8 +850,8 @@ edit_command (char *arg, int from_tty) error (_("No line number known for %s."), arg); } - if ((editor = (char *) getenv ("EDITOR")) == NULL) - editor = "/bin/ex"; + if ((editor = getenv ("EDITOR")) == NULL) + editor = "/bin/ex"; fn = symtab_to_fullname (sal.symtab); @@ -891,7 +863,7 @@ edit_command (char *arg, int from_tty) } static void -list_command (char *arg, int from_tty) +list_command (const char *arg, int from_tty) { struct symbol *sym; const char *arg1; @@ -899,7 +871,7 @@ list_command (char *arg, int from_tty) int dummy_end = 0; int dummy_beg = 0; int linenum_beg = 0; - char *p; + const char *p; /* Pull in the current default source line if necessary. */ if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0')) @@ -1082,7 +1054,7 @@ list_command (char *arg, int from_tty) turn it into the no-arg variant. */ if (from_tty) - *arg = 0; + set_repeat_arguments (""); if (dummy_beg && sal_end.symtab == 0) error (_("No default source file yet. Do \"help list\".")); @@ -1120,11 +1092,15 @@ list_command (char *arg, int from_tty) Perform the disassembly. NAME is the name of the function if known, or NULL. [LOW,HIGH) are the range of addresses to disassemble. + BLOCK is the block to disassemble; it needs to be provided + when non-contiguous blocks are disassembled; otherwise + it can be NULL. MIXED is non-zero to print source with the assembler. */ static void print_disassembly (struct gdbarch *gdbarch, const char *name, CORE_ADDR low, CORE_ADDR high, + const struct block *block, gdb_disassembly_flags flags) { #if defined(TUI) @@ -1133,14 +1109,28 @@ print_disassembly (struct gdbarch *gdbarch, const char *name, { printf_filtered ("Dump of assembler code "); if (name != NULL) - printf_filtered ("for function %s:\n", name); - else - printf_filtered ("from %s to %s:\n", - paddress (gdbarch, low), paddress (gdbarch, high)); - - /* Dump the specified range. */ - gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high); + printf_filtered ("for function %s:\n", name); + if (block == nullptr || BLOCK_CONTIGUOUS_P (block)) + { + if (name == NULL) + printf_filtered ("from %s to %s:\n", + paddress (gdbarch, low), paddress (gdbarch, high)); + /* Dump the specified range. */ + gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high); + } + else + { + for (int i = 0; i < BLOCK_NRANGES (block); i++) + { + CORE_ADDR low = BLOCK_RANGE_START (block, i); + CORE_ADDR high = BLOCK_RANGE_END (block, i); + printf_filtered (_("Address range %s to %s:\n"), + paddress (gdbarch, low), + paddress (gdbarch, high)); + gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high); + } + } printf_filtered ("End of assembler dump.\n"); gdb_flush (gdb_stdout); } @@ -1162,11 +1152,12 @@ disassemble_current_function (gdb_disassembly_flags flags) struct gdbarch *gdbarch; CORE_ADDR low, high, pc; const char *name; + const struct block *block; frame = get_selected_frame (_("No frame selected.")); gdbarch = get_frame_arch (frame); pc = get_frame_address_in_block (frame); - if (find_pc_partial_function (pc, &name, &low, &high) == 0) + if (find_pc_partial_function (pc, &name, &low, &high, &block) == 0) error (_("No function contains program counter for selected frame.")); #if defined(TUI) /* NOTE: cagney/2003-02-13 The `tui_active' was previously @@ -1177,7 +1168,7 @@ disassemble_current_function (gdb_disassembly_flags flags) #endif low += gdbarch_deprecated_function_start_offset (gdbarch); - print_disassembly (gdbarch, name, low, high, flags); + print_disassembly (gdbarch, name, low, high, block, flags); } /* Dump a specified section of assembly code. @@ -1205,7 +1196,7 @@ disassemble_current_function (gdb_disassembly_flags flags) 2) File names and contents for all relevant source files are displayed. */ static void -disassemble_command (char *arg, int from_tty) +disassemble_command (const char *arg, int from_tty) { struct gdbarch *gdbarch = get_current_arch (); CORE_ADDR low, high; @@ -1213,6 +1204,7 @@ disassemble_command (char *arg, int from_tty) CORE_ADDR pc; gdb_disassembly_flags flags; const char *p; + const struct block *block = nullptr; p = arg; name = NULL; @@ -1263,7 +1255,7 @@ disassemble_command (char *arg, int from_tty) if (p[0] == '\0') { /* One argument. */ - if (find_pc_partial_function (pc, &name, &low, &high) == 0) + if (find_pc_partial_function (pc, &name, &low, &high, &block) == 0) error (_("No function contains specified address.")); #if defined(TUI) /* NOTE: cagney/2003-02-13 The `tui_active' was previously @@ -1291,11 +1283,11 @@ disassemble_command (char *arg, int from_tty) high += low; } - print_disassembly (gdbarch, name, low, high, flags); + print_disassembly (gdbarch, name, low, high, block, flags); } static void -make_command (char *arg, int from_tty) +make_command (const char *arg, int from_tty) { if (arg == 0) shell_escape ("make", from_tty); @@ -1336,7 +1328,7 @@ show_user (const char *args, int from_tty) regular expression. */ static void -apropos_command (char *searchstr, int from_tty) +apropos_command (const char *searchstr, int from_tty) { if (searchstr == NULL) error (_("REGEXP string is empty")); @@ -1405,11 +1397,11 @@ alias_usage_error (void) /* Make an alias of an existing command. */ static void -alias_command (char *args, int from_tty) +alias_command (const char *args, int from_tty) { int i, alias_argc, command_argc; int abbrev_flag = 0; - char *equals; + const char *equals; const char *alias, *command; if (args == NULL || strchr (args, '=') == NULL)