X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Freverse.c;h=a1b697f4d21ea9dca68d55d3cb83e1a2e1e25ff2;hb=a14d1f4dfc08edc8fe92b17b36a55d89203fb89f;hp=d30116083fe4ad9849fb6b3b125186184eaee802;hpb=6b04bdb74a44bebb3d4931de23ae39b0315d06b6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/reverse.c b/gdb/reverse.c index d30116083f..a1b697f4d2 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -1,6 +1,6 @@ /* Reverse execution and reverse debugging. - Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2006-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -18,12 +18,13 @@ along with this program. If not, see . */ #include "defs.h" -#include "gdb_string.h" #include "target.h" #include "top.h" #include "cli/cli-cmds.h" #include "cli/cli-decode.h" +#include "cli/cli-utils.h" #include "inferior.h" +#include "infrun.h" #include "regcache.h" /* User interface: @@ -48,9 +49,6 @@ exec_reverse_once (char *cmd, char *args, int from_tty) enum exec_direction_kind dir = execution_direction; struct cleanup *old_chain; - if (dir == EXEC_ERROR) - error (_("Target %s does not support this command."), target_shortname); - if (dir == EXEC_REVERSE) error (_("Already in reverse mode. Use '%s' or 'set exec-dir forward'."), cmd); @@ -144,7 +142,7 @@ save_bookmark_command (char *args, int from_tty) error (_("target_get_bookmark failed.")); /* Set up a bookmark struct. */ - b = xcalloc (1, sizeof (struct bookmark)); + b = XCNEW (struct bookmark); b->number = ++bookmark_count; init_sal (&b->sal); b->pc = regcache_read_pc (get_current_regcache ()); @@ -172,15 +170,20 @@ save_bookmark_command (char *args, int from_tty) /* Implement "delete bookmark" command. */ static int -delete_one_bookmark (struct bookmark *b) +delete_one_bookmark (int num) { - struct bookmark *b1; + struct bookmark *b1, *b; + + /* Find bookmark with corresponding number. */ + ALL_BOOKMARKS (b) + if (b->number == num) + break; /* Special case, first item in list. */ if (b == bookmark_chain) bookmark_chain = b->next; - /* Find bookmark preceeding "marked" one, so we can unlink. */ + /* Find bookmark preceding "marked" one, so we can unlink. */ if (b) { ALL_BOOKMARKS (b1) @@ -213,8 +216,8 @@ delete_all_bookmarks (void) static void delete_bookmark_command (char *args, int from_tty) { - struct bookmark *b, *b1; - unsigned long num; + int num; + struct get_number_or_range_state state; if (bookmark_chain == NULL) { @@ -230,15 +233,14 @@ delete_bookmark_command (char *args, int from_tty) return; } - num = strtoul (args, NULL, 0); - /* Find bookmark with corresponding number. */ - ALL_BOOKMARKS (b) - if (b->number == num) - break; - - if (!delete_one_bookmark (b)) - /* Not found. */ - error (_("delete bookmark: no bookmark found for '%s'."), args); + init_number_or_range (&state, args); + while (!state.finished) + { + num = get_number_or_range (&state); + if (!delete_one_bookmark (num)) + /* Not found. */ + warning (_("No bookmark #%d."), num); + } } /* Implement "goto-bookmark" command. */ @@ -248,16 +250,17 @@ goto_bookmark_command (char *args, int from_tty) { struct bookmark *b; unsigned long num; + char *p = args; if (args == NULL || args[0] == '\0') error (_("Command requires an argument.")); - if (strncmp (args, "start", strlen ("start")) == 0 - || strncmp (args, "begin", strlen ("begin")) == 0 - || strncmp (args, "end", strlen ("end")) == 0) + if (startswith (args, "start") + || startswith (args, "begin") + || startswith (args, "end")) { /* Special case. Give target opportunity to handle. */ - target_goto_bookmark (args, from_tty); + target_goto_bookmark ((gdb_byte *) args, from_tty); return; } @@ -266,12 +269,16 @@ goto_bookmark_command (char *args, int from_tty) /* Special case -- quoted string. Pass on to target. */ if (args[strlen (args) - 1] != args[0]) error (_("Unbalanced quotes: %s"), args); - target_goto_bookmark (args, from_tty); + target_goto_bookmark ((gdb_byte *) args, from_tty); return; } /* General case. Bookmark identified by bookmark number. */ - num = strtoul (args, NULL, 0); + num = get_number (&args); + + if (num == 0) + error (_("goto-bookmark: invalid bookmark number '%s'."), p); + ALL_BOOKMARKS (b) if (b->number == num) break; @@ -283,7 +290,32 @@ goto_bookmark_command (char *args, int from_tty) return; } /* Not found. */ - error (_("goto-bookmark: no bookmark found for '%s'."), args); + error (_("goto-bookmark: no bookmark found for '%s'."), p); +} + +static int +bookmark_1 (int bnum) +{ + struct gdbarch *gdbarch = get_regcache_arch (get_current_regcache ()); + struct bookmark *b; + int matched = 0; + + ALL_BOOKMARKS (b) + { + if (bnum == -1 || bnum == b->number) + { + printf_filtered (" %d %s '%s'\n", + b->number, + paddress (gdbarch, b->pc), + b->opaque_data); + matched++; + } + } + + if (bnum > 0 && matched == 0) + printf_filtered ("No bookmark #%d\n", bnum); + + return matched; } /* Implement "info bookmarks" command. */ @@ -291,28 +323,23 @@ goto_bookmark_command (char *args, int from_tty) static void bookmarks_info (char *args, int from_tty) { - struct bookmark *b; int bnum = -1; - struct gdbarch *gdbarch; - - if (args) - bnum = parse_and_eval_long (args); if (!bookmark_chain) + printf_filtered (_("No bookmarks.\n")); + else if (args == NULL || *args == '\0') + bookmark_1 (-1); + else { - printf_filtered (_("No bookmarks.\n")); - return; + struct get_number_or_range_state state; + + init_number_or_range (&state, args); + while (!state.finished) + { + bnum = get_number_or_range (&state); + bookmark_1 (bnum); + } } - - gdbarch = get_regcache_arch (get_current_regcache ()); - printf_filtered (_("Bookmark Address Opaque\n")); - printf_filtered (_(" ID Data \n")); - - ALL_BOOKMARKS (b) - printf_filtered (" %d %s '%s'\n", - b->number, - paddress (gdbarch, b->pc), - b->opaque_data); } @@ -369,7 +396,8 @@ execution history that can be returned to later in the same debug \n\ session.")); add_cmd ("bookmark", class_bookmark, delete_bookmark_command, _("\ Delete a bookmark from the bookmark list.\n\ -Argument is a bookmark number, or no argument to delete all bookmarks.\n"), +Argument is a bookmark number or numbers,\n\ + or no argument to delete all bookmarks.\n"), &deletelist); add_com ("goto-bookmark", class_bookmark, goto_bookmark_command, _("\ Go to an earlier-bookmarked point in the program's execution history.\n\