diff options
author | Tom Tromey <tromey@redhat.com> | 2013-04-15 08:59:03 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-06-26 09:14:16 -0600 |
commit | c2bcbb1d04bb46a130f2c84de05cbbdccc0645fc (patch) | |
tree | 57a628fb31746a0ac6f918a08f6d9c67f5a81ca6 /gdb/record-full.c | |
parent | 9cbe5fff2b47da85dbc628bdc8c6a85d5344749a (diff) |
constify get_bookmark and goto_bookmark
This makes arguments to to_get_bookmark and to_goto_bookmark const and
fixes the fallout. Tested by rebuilding. The only thing of note is
the new split between cmd_record_goto and record_goto -- basically
separating the CLI function from a new internal API, to allow const
propagation.
2014-06-26 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_get_bookmark): Make "args" const.
(record_full_goto_bookmark): Make "raw_bookmark" const.
* record.c (record_goto): New function.
(cmd_record_goto): Use it. Now static.
* record.h (record_goto): Declare.
(cmd_record_goto): Remove declaration.
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_get_bookmark,
to_goto_bookmark>: Make parameter const.
Diffstat (limited to 'gdb/record-full.c')
-rw-r--r-- | gdb/record-full.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gdb/record-full.c b/gdb/record-full.c index a496cf32e1..fcd7790863 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1703,7 +1703,8 @@ record_full_can_execute_reverse (struct target_ops *self) /* "to_get_bookmark" method for process record and prec over core. */ static gdb_byte * -record_full_get_bookmark (struct target_ops *self, char *args, int from_tty) +record_full_get_bookmark (struct target_ops *self, const char *args, + int from_tty) { char *ret = NULL; @@ -1727,9 +1728,10 @@ record_full_get_bookmark (struct target_ops *self, char *args, int from_tty) static void record_full_goto_bookmark (struct target_ops *self, - gdb_byte *raw_bookmark, int from_tty) + const gdb_byte *raw_bookmark, int from_tty) { - char *bookmark = (char *) raw_bookmark; + const char *bookmark = (const char *) raw_bookmark; + struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); if (record_debug) fprintf_unfiltered (gdb_stdlog, @@ -1737,18 +1739,20 @@ record_full_goto_bookmark (struct target_ops *self, if (bookmark[0] == '\'' || bookmark[0] == '\"') { + char *copy; + if (bookmark[strlen (bookmark) - 1] != bookmark[0]) error (_("Unbalanced quotes: %s"), bookmark); - /* Strip trailing quote. */ - bookmark[strlen (bookmark) - 1] = '\0'; - /* Strip leading quote. */ - bookmark++; - /* Pass along to cmd_record_full_goto. */ + + copy = savestring (bookmark + 1, strlen (bookmark) - 2); + make_cleanup (xfree, copy); + bookmark = copy; } - cmd_record_goto (bookmark, from_tty); - return; + record_goto (bookmark); + + do_cleanups (cleanup); } static enum exec_direction_kind |