+ ALL_BOOKMARKS_SAFE (b, b1)
+ {
+ xfree (b->opaque_data);
+ xfree (b);
+ }
+ bookmark_chain = NULL;
+}
+
+static void
+delete_bookmark_command (const char *args, int from_tty)
+{
+ if (bookmark_chain == NULL)
+ {
+ warning (_("No bookmarks."));
+ return;
+ }
+
+ if (args == NULL || args[0] == '\0')
+ {
+ if (from_tty && !query (_("Delete all bookmarks? ")))
+ return;
+ delete_all_bookmarks ();
+ return;
+ }
+
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
+ {
+ int num = parser.get_number ();
+ if (!delete_one_bookmark (num))
+ /* Not found. */
+ warning (_("No bookmark #%d."), num);
+ }
+}
+
+/* Implement "goto-bookmark" command. */
+
+static void
+goto_bookmark_command (const char *args, int from_tty)
+{
+ struct bookmark *b;
+ unsigned long num;
+ const char *p = args;
+
+ if (args == NULL || args[0] == '\0')
+ error (_("Command requires an argument."));
+
+ if (startswith (args, "start")
+ || startswith (args, "begin")
+ || startswith (args, "end"))
+ {
+ /* Special case. Give target opportunity to handle. */
+ target_goto_bookmark ((gdb_byte *) args, from_tty);
+ return;
+ }
+
+ if (args[0] == '\'' || args[0] == '\"')
+ {
+ /* Special case -- quoted string. Pass on to target. */
+ if (args[strlen (args) - 1] != args[0])
+ error (_("Unbalanced quotes: %s"), args);
+ target_goto_bookmark ((gdb_byte *) args, from_tty);
+ return;
+ }
+
+ /* General case. Bookmark identified by bookmark number. */
+ num = get_number (&args);
+
+ if (num == 0)
+ error (_("goto-bookmark: invalid bookmark number '%s'."), p);
+
+ ALL_BOOKMARKS (b)
+ if (b->number == num)
+ break;
+
+ if (b)
+ {
+ /* Found. Send to target method. */
+ target_goto_bookmark (b->opaque_data, from_tty);
+ return;
+ }
+ /* Not found. */
+ error (_("goto-bookmark: no bookmark found for '%s'."), p);
+}
+
+static int
+bookmark_1 (int bnum)
+{
+ struct gdbarch *gdbarch = get_current_regcache ()->arch ();
+ 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. */
+
+static void
+info_bookmarks_command (const char *args, int from_tty)
+{
+ if (!bookmark_chain)
+ printf_filtered (_("No bookmarks.\n"));
+ else if (args == NULL || *args == '\0')
+ bookmark_1 (-1);
+ else
+ {
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
+ {
+ int bnum = parser.get_number ();
+ bookmark_1 (bnum);
+ }
+ }
+}
+
+void _initialize_reverse ();