diff options
author | Tom Tromey <tom@tromey.com> | 2017-08-11 14:48:17 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-03 13:03:03 -0600 |
commit | 7ffd83d70f2792a8a538e8599959a6ed7f5b751d (patch) | |
tree | 22b26fd05fa325a750d050b92b0cb1f4bf28d8bd /gdb/thread.c | |
parent | 1ccbe9985f607b291bb6fc920beda60225f1bf83 (diff) | |
download | gdb-7ffd83d70f2792a8a538e8599959a6ed7f5b751d.zip gdb-7ffd83d70f2792a8a538e8599959a6ed7f5b751d.tar.gz gdb-7ffd83d70f2792a8a538e8599959a6ed7f5b751d.tar.bz2 |
Use std::string thread.c
This changes a few spots in thread.c to use std::string, removing some
cleanups.
ChangeLog
2017-09-03 Tom Tromey <tom@tromey.com>
* thread.c (print_thread_info_1): Use string_printf.
(thread_apply_command, thread_apply_all_command): Use
std::string.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r-- | gdb/thread.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/gdb/thread.c b/gdb/thread.c index 3cf1b94..8a0ed0c 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1343,22 +1343,19 @@ print_thread_info_1 (struct ui_out *uiout, char *requested_threads, } else { - struct cleanup *str_cleanup; - char *contents; + std::string contents; if (extra_info && name) - contents = xstrprintf ("%s \"%s\" (%s)", target_id, - name, extra_info); + contents = string_printf ("%s \"%s\" (%s)", target_id, + name, extra_info); else if (extra_info) - contents = xstrprintf ("%s (%s)", target_id, extra_info); + contents = string_printf ("%s (%s)", target_id, extra_info); else if (name) - contents = xstrprintf ("%s \"%s\"", target_id, name); + contents = string_printf ("%s \"%s\"", target_id, name); else - contents = xstrdup (target_id); - str_cleanup = make_cleanup (xfree, contents); + contents = target_id; - uiout->field_string ("target-id", contents); - do_cleanups (str_cleanup); + uiout->field_string ("target-id", contents.c_str ()); } if (tp->state == THREAD_RUNNING) @@ -1701,8 +1698,6 @@ tp_array_compar (const thread_info *a, const thread_info *b) static void thread_apply_all_command (char *cmd, int from_tty) { - char *saved_cmd; - tp_array_compar_ascending = false; if (cmd != NULL && check_for_argument (&cmd, "-ascending", strlen ("-ascending"))) @@ -1718,8 +1713,7 @@ thread_apply_all_command (char *cmd, int from_tty) /* Save a copy of the command in case it is clobbered by execute_command. */ - saved_cmd = xstrdup (cmd); - make_cleanup (xfree, saved_cmd); + std::string saved_cmd = cmd; int tc = live_threads_count (); if (tc != 0) @@ -1761,7 +1755,7 @@ thread_apply_all_command (char *cmd, int from_tty) execute_command (cmd, from_tty); /* Restore exact command used previously. */ - strcpy (cmd, saved_cmd); + strcpy (cmd, saved_cmd.c_str ()); } } } @@ -1772,8 +1766,6 @@ static void thread_apply_command (char *tidlist, int from_tty) { char *cmd = NULL; - struct cleanup *old_chain; - char *saved_cmd; tid_range_parser parser; if (tidlist == NULL || *tidlist == '\000') @@ -1799,8 +1791,7 @@ thread_apply_command (char *tidlist, int from_tty) /* Save a copy of the command in case it is clobbered by execute_command. */ - saved_cmd = xstrdup (cmd); - old_chain = make_cleanup (xfree, saved_cmd); + std::string saved_cmd = cmd; scoped_restore_current_thread restore_thread; @@ -1857,10 +1848,8 @@ thread_apply_command (char *tidlist, int from_tty) execute_command (cmd, from_tty); /* Restore exact command used previously. */ - strcpy (cmd, saved_cmd); + strcpy (cmd, saved_cmd.c_str ()); } - - do_cleanups (old_chain); } /* Switch to the specified thread. Will dispatch off to thread_apply_command |