#include <algorithm>
#include "common/gdb_optional.h"
#include "inline-frame.h"
+#include "stack.h"
/* Definition of struct thread_info exported to gdbthread.h. */
/* See gdbthread.h. */
struct thread_info *
-find_thread_by_handle (struct value *thread_handle, struct inferior *inf)
+find_thread_by_handle (gdb::array_view<const gdb_byte> handle,
+ struct inferior *inf)
{
- return target_thread_handle_to_thread_info
- (value_contents_all (thread_handle),
- TYPE_LENGTH (value_type (thread_handle)),
- inf);
+ return target_thread_handle_to_thread_info (handle.data (),
+ handle.size (),
+ inf);
}
/*
/* See gdbthread.h. */
void
-print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
+print_thread_info (struct ui_out *uiout, const char *requested_threads,
+ int pid)
{
print_thread_info_1 (uiout, requested_threads, 1, pid, 0);
}
const qcs_flags &flags)
{
switch_to_thread (thr);
- TRY
+ try
{
- std::string cmd_result = execute_command_to_string (cmd, from_tty);
+ std::string cmd_result = execute_command_to_string
+ (cmd, from_tty, gdb_stdout->term_out ());
if (!flags.silent || cmd_result.length () > 0)
{
if (!flags.quiet)
printf_filtered ("%s", cmd_result.c_str ());
}
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
if (!flags.silent)
{
if (flags.cont)
printf_filtered ("%s\n", ex.what ());
else
- throw_exception (ex);
+ throw;
}
}
- END_CATCH;
}
/* Apply a GDB command to a list of threads. List syntax is a whitespace
{
qcs_flags flags;
const char *cmd = NULL;
- const char *cmd_or_flags;
tid_range_parser parser;
if (tidlist == NULL || *tidlist == '\000')
int inf_num, thr_start, thr_end;
if (!parser.get_tid_range (&inf_num, &thr_start, &thr_end))
- {
- cmd = parser.cur_tok ();
- break;
- }
+ break;
}
- cmd_or_flags = cmd;
- while (cmd != NULL && parse_flags_qcs ("thread apply", &cmd, &flags))
+ cmd = parser.cur_tok ();
+
+ while (parse_flags_qcs ("thread apply", &cmd, &flags))
;
- if (cmd == NULL)
+ if (*cmd == '\0')
error (_("Please specify a command following the thread ID list"));
- if (tidlist == cmd || !isalpha (cmd[0]))
+ if (tidlist == cmd || isdigit (cmd[0]))
invalid_thread_id_error (cmd);
scoped_restore_current_thread restore_thread;
parser.init (tidlist, current_inferior ()->num);
- while (!parser.finished () && parser.cur_tok () < cmd_or_flags)
+ while (!parser.finished ())
{
struct thread_info *tp = NULL;
struct inferior *inf;
tfaas_command (const char *cmd, int from_tty)
{
std::string expanded
- = std::string ("thread apply all -s frame apply all -s ") + cmd;
+ = std::string ("thread apply all -s -- frame apply all -s ") + cmd;
execute_command (expanded.c_str (), from_tty);
}
_initialize_thread (void)
{
static struct cmd_list_element *thread_apply_list = NULL;
+ cmd_list_element *c;
add_info ("threads", info_threads_command,
_("Display currently known threads.\n\
Usage: taas COMMAND\n\
shortcut for 'thread apply all -s COMMAND'"));
- add_com ("tfaas", class_run, tfaas_command, _("\
+ c = add_com ("tfaas", class_run, tfaas_command, _("\
Apply a command to all frames of all threads (ignoring errors and empty output).\n\
-Usage: tfaas COMMAND\n\
-shortcut for 'thread apply all -s frame apply all -s COMMAND'"));
+Usage: tfaas [OPTION]... COMMAND\n\
+shortcut for 'thread apply all -s -- frame apply all -s [OPTION]... COMMAND'\n\
+See \"help frame apply all\" for available options."));
+ set_cmd_completer_handle_brkchars (c, frame_apply_all_cmd_completer);
add_cmd ("name", class_run, thread_name_command,
_("Set the current thread's name.\n\