34#define KNOWN_TASKS_NAME "system__tasking__debug__known_tasks"
42#define KNOWN_TASKS_LIST "system__tasking__debug__first_task"
71 N_(
"Child Activation Wait"),
72 N_(
"Accept or Select Term"),
73 N_(
"Waiting on entry call"),
74 N_(
"Async Select Wait"),
76 N_(
"Child Termination Wait"),
77 N_(
"Wait Child in Term Alt"),
82 N_(
"Asynchronous Hold"),
97 static char buffer[100];
98 xsnprintf (buffer,
sizeof (buffer), _(
"Unknown task state: %d"),
value);
107 N_(
"Waiting for child activation"),
108 N_(
"Blocked in accept or select with terminate"),
109 N_(
"Waiting on entry call"),
110 N_(
"Asynchronous Selective Wait"),
112 N_(
"Waiting for children termination"),
113 N_(
"Waiting for children in terminate alternative"),
118 N_(
"Asynchronous Hold"),
121 N_(
"Blocked in selective wait statement")
134 static char buffer[100];
135 xsnprintf (buffer,
sizeof (buffer), _(
"Unknown task state: %d"),
value);
283 if (task_info->
name[0] ==
'\0')
284 return string_printf (
"%d", taskno);
286 return string_printf (
"%d \"%s\"", taskno, task_info->
name);
339 gdb_assert (
inf != NULL);
342 for (
int i = 0; i < data->task_list.size (); i++)
343 if (data->task_list[i].ptid == thread->
ptid)
357 for (
int i = 0; i < data->task_list.size (); i++)
359 if (data->task_list[i].task_id == task_id)
376 return task_num > 0 && task_num <= data->task_list.size ();
401 if (task.ptid == ptid)
433 memcpy (dest, val->
contents ().data (), length);
445 struct value *array_val;
446 struct value *bounds_val;
451 static int initialize_fieldnos = 1;
452 static int array_fieldno;
453 static int bounds_fieldno;
454 static int upper_bound_fieldno;
458 if (initialize_fieldnos)
461 struct type *bounds_type;
467 if (bounds_type->
code () == TYPE_CODE_PTR)
469 if (bounds_type->
code () != TYPE_CODE_STRUCT)
470 error (_(
"Unknown task name format. Aborting"));
473 initialize_fieldnos = 0;
506 struct type *common_type;
507 struct type *ll_type;
508 struct type *call_type;
512 const char *atcb_name =
"system__tasking__ada_task_control_block___XVE";
513 const char *atcb_name_fixed =
"system__tasking__ada_task_control_block";
514 const char *common_atcb_name =
"system__tasking__common_atcb";
515 const char *private_data_name =
"system__task_primitives__private_data";
516 const char *entry_call_record_name =
"system__tasking__entry_call_record";
525 const struct symbol *common_atcb_sym =
528 const struct symbol *private_data_sym =
531 const struct symbol *entry_call_record_sym =
535 if (atcb_sym == NULL || atcb_sym->
type () == NULL)
543 if (atcb_sym == NULL || atcb_sym->
type () == NULL)
544 return _(
"Cannot find Ada_Task_Control_Block type");
556 if (common_atcb_sym == NULL || common_atcb_sym->
type () == NULL)
557 return _(
"Cannot find Common_ATCB type");
558 if (private_data_sym == NULL || private_data_sym->
type ()== NULL)
559 return _(
"Cannot find Private_Data type");
560 if (entry_call_record_sym == NULL || entry_call_record_sym->
type () == NULL)
561 return _(
"Cannot find Entry_Call_Record type");
564 common_type = common_atcb_sym->
type ();
567 ll_type = private_data_sym->
type ();
570 call_type = entry_call_record_sym->
type ();
583 "activation_link", 1);
603 unsigned int first_id = 0;
604 if (first_id_sym.
minsym !=
nullptr)
634 struct value *ll_value;
659 struct value *tcb_value;
660 struct value *common_value;
661 struct value *atc_nesting_level_value;
662 struct value *entry_calls_value;
663 struct value *entry_calls_value_element;
664 int called_task_fieldno = -1;
665 static const char ravenscar_task_name[] =
"Ravenscar task";
678 error (_(
"%s. Aborting"), err_msg);
710 sizeof (task_info->
name) - 1);
719 const char *task_name = full_name;
723 for (p = full_name; *p; p++)
724 if (p[0] ==
'_' && p[1] ==
'_')
728 strncpy (task_info->
name, task_name,
729 sizeof (task_info->
name) - 1);
730 task_info->
name[
sizeof (task_info->
name) - 1] = 0;
735 strcpy (task_info->
name, ravenscar_task_name);
778 atc_nesting_level_value =
783 entry_calls_value_element =
786 called_task_fieldno =
791 called_task_fieldno));
801 const CORE_ADDR call =
804 struct value *call_val;
828 task_info->
ptid = null_ptid;
841 data->task_list.push_back (task_info);
850 const int target_ptr_byte = data->known_tasks_element->length ();
851 const int known_tasks_size = target_ptr_byte * data->known_tasks_length;
852 gdb_byte *known_tasks = (gdb_byte *) alloca (known_tasks_size);
857 read_memory (data->known_tasks_addr, known_tasks, known_tasks_size);
858 for (i = 0; i < data->known_tasks_length; i++)
862 data->known_tasks_element);
877 const int target_ptr_byte = data->known_tasks_element->length ();
878 gdb_byte *known_tasks = (gdb_byte *) alloca (target_ptr_byte);
888 read_memory (data->known_tasks_addr, known_tasks, target_ptr_byte);
892 struct value *tcb_value;
893 struct value *common_value;
937 struct type *eltype = NULL;
938 struct type *idxtype = NULL;
940 if (
type->
code () == TYPE_CODE_ARRAY)
943 && eltype->
code () == TYPE_CODE_PTR)
949 data->known_tasks_element = eltype;
950 data->known_tasks_length =
961 data->known_tasks_element =
975 data->known_tasks_length = 1;
986 data->known_tasks_element =
type;
992 data->known_tasks_element =
994 data->known_tasks_length = 1;
1001 data->known_tasks_addr = 0;
1014 data->task_list.clear ();
1027 switch (data->known_tasks_kind)
1050 error (_(
"Cannot inspect Ada tasks when program is not running"));
1053 if (!data->task_list_valid_p)
1056 return data->task_list.size ();
1066 const char *arg_str,
1070 int taskno, nb_tasks;
1076 uiout->
message (_(
"Your application does not use any Ada tasks.\n"));
1080 if (arg_str != NULL && arg_str[0] !=
'\0')
1100 if (taskno_arg > 0 && taskno_arg <= data->
task_list.size ())
1106 nb_tasks = data->task_list.size ();
1113 size_t tid_width = 9;
1118 for (taskno = 1; taskno <= data->task_list.size (); taskno++)
1121 = &data->task_list[taskno - 1];
1123 gdb_assert (task_info != NULL);
1125 tid_width = std::max (tid_width,
1126 1 + strlen (phex_nz (task_info->
task_id,
1127 sizeof (CORE_ADDR))));
1146 for (taskno = 1; taskno <= data->task_list.size (); taskno++)
1149 &data->task_list[taskno - 1];
1152 gdb_assert (task_info != NULL);
1157 if (taskno_arg && taskno != taskno_arg)
1174 sizeof (CORE_ADDR)));
1180 ?
inf->find_thread (task_info->
ptid)
1205 _(
"Accepting RV with %-4d"),
1210 _(
"Waiting on RV with %-3d"),
1220 (task_info->
name[0] !=
'\0'
1224 (task_info->
name[0] !=
'\0'
1240 int parent_taskno = 0;
1245 uiout->
message (_(
"Your application does not use any Ada tasks.\n"));
1249 if (taskno <= 0 || taskno > data->task_list.size ())
1250 error (_(
"Task ID %d not known. Use the \"info tasks\" command to\n"
1251 "see the IDs of currently known tasks"), taskno);
1252 task_info = &data->task_list[taskno - 1];
1259 if (task_info->
name[0] !=
'\0')
1265 gdb_printf (_(
"Thread: 0x%s\n"), phex_nz (task_info->
ptid.tid (),
1266 sizeof (ULONGEST)));
1274 if (task_info->
parent != 0)
1281 if (
parent->name[0] !=
'\0')
1293 int target_taskno = 0;
1298 gdb_printf (_(
"State: Accepting rendezvous with %d"),
1304 gdb_printf (_(
"State: Waiting on task %d's entry"),
1312 ada_task_info *target_task_info = &data->task_list[target_taskno - 1];
1314 if (target_task_info->
name[0] !=
'\0')
1333 if (arg == NULL || *arg ==
'\0')
1347 if (current_task == 0)
1348 gdb_printf (_(
"[Current task is unknown]\n"));
1353 struct ada_task_info *task_info = &data->task_list[current_task - 1];
1370 if (taskno <= 0 || taskno > data->task_list.size ())
1371 error (_(
"Task ID %d not known. Use the \"info tasks\" command to\n"
1372 "see the IDs of currently known tasks"), taskno);
1373 task_info = &data->task_list[taskno - 1];
1376 error (_(
"Cannot switch to task %s: Task is no longer running"),
1398 error (_(
"Unable to compute thread ID for task %s.\n"
1399 "Cannot switch to this task."),
1422 uiout->
message (_(
"Your application does not use any Ada tasks.\n"));
1426 if (taskno_str == NULL || taskno_str[0] ==
'\0')
1440 data->task_list_valid_p =
false;
1459 data->task_list_valid_p =
false;
1485 if (
inf->pspace == pspace)
1505 "q", [] (
qcs_flags *opt) {
return &opt->quiet; },
1506 N_(
"Disables printing the task information."),
1510 "c", [] (
qcs_flags *opt) {
return &opt->cont; },
1511 N_(
"Print any error raised by COMMAND and continue."),
1515 "s", [] (
qcs_flags *opt) {
return &opt->silent; },
1516 N_(
"Silently ignore any errors or empty output produced by COMMAND."),
1523static inline std::array<gdb::option::option_def_group, 1>
1553 if (cmd ==
nullptr || *cmd ==
'\0')
1554 error (_(
"Please specify a command at the end of 'task apply all'"));
1565 std::vector<std::pair<int, thread_info_ref>> thr_list_cpy;
1567 for (
int i = 1; i <= data->task_list.size (); ++i)
1575 warning (_(
"Unable to compute thread ID for task %s.\n"
1576 "Cannot switch to this task."),
1579 thr_list_cpy.emplace_back (i, thread_info_ref::new_reference (tp));
1584 for (
const auto &info : thr_list_cpy)
1596 if (tidlist ==
nullptr || *tidlist ==
'\0')
1597 error (_(
"Please specify a task ID list"));
1608 std::vector<std::pair<int, thread_info_ref>> thr_list_cpy;
1615 if (num < 1 || num - 1 >= data->task_list.size ())
1616 warning (_(
"no Ada Task with number %d"), num);
1625 warning (_(
"Unable to compute thread ID for task %s.\n"
1626 "Cannot switch to this task."),
1629 thr_list_cpy.emplace_back (num,
1630 thread_info_ref::new_reference (tp));
1635 const char *cmd = parser.
cur_tok ();
1644 error (_(
"Please specify a command following the task ID list"));
1648 for (
const auto &info : thr_list_cpy)
1672 _(
"Provide information about all known Ada tasks."));
1675 _(
"Use this command to switch between Ada tasks.\n\
1676Without argument, this command simply prints the current task ID."),
1679#define TASK_APPLY_OPTION_HELP "\
1680Prints per-inferior task number followed by COMMAND output.\n\
1682By default, an error raised during the execution of COMMAND\n\
1683aborts \"task apply\".\n\
1688 static const auto task_apply_opts
1692Apply a command to a list of tasks.\n\
1693Usage: task apply ID... [OPTION]... COMMAND\n\
1694ID is a space-separated list of IDs of tasks to apply COMMAND on.\n"
1699 task_apply_help.c_str (),
1700 &task_apply_list, 1,
1703 static const auto task_apply_all_opts
1707Apply a command to all tasks in the current inferior.\n\
1709Usage: task apply all [OPTION]... COMMAND\n"
1713 task_apply_all_help.c_str (), &task_apply_list);
struct value * ada_coerce_to_simple_array_ptr(struct value *arr)
void ada_find_printable_frame(frame_info_ptr fi)
struct type * ada_template_to_fixed_record_type_1(struct type *type, const gdb_byte *valaddr, CORE_ADDR address, struct value *dval0, int keep_dynamic_fields)
int ada_get_field_index(const struct type *type, const char *field_name, int maybe_missing)
gdb::function_view< void(struct ada_task_info *task) ada_task_list_iterator_ftype)
static void info_tasks_command(const char *arg, int from_tty)
static int get_task_number_from_id(CORE_ADDR task_id, struct inferior *inf)
static void read_fat_string_value(char *dest, struct value *val, int max_len)
int ada_get_task_number(thread_info *thread)
static const registry< program_space >::key< ada_tasks_pspace_data > ada_tasks_pspace_data_handle
static void ada_tasks_inferior_data_sniffer(struct ada_tasks_inferior_data *data)
static const gdb::option::option_def task_qcs_flags_option_defs[]
static bool read_known_tasks_list(struct ada_tasks_inferior_data *data)
struct ada_task_info * ada_get_task_info_from_ptid(ptid_t ptid)
static void display_current_task_id(void)
static void task_command(const char *taskno_str, int from_tty)
static const char *const long_task_states[]
static const registry< inferior >::key< ada_tasks_inferior_data > ada_tasks_inferior_data_handle
static void value_as_string(char *dest, struct value *val, int length)
static gdb::option::option_def_group make_task_apply_options_def_group(qcs_flags *flags)
static void task_command_1(const char *taskno_str, int from_tty, struct inferior *inf)
int valid_task_id(int task_num)
static std::string task_to_str(int taskno, const ada_task_info *task_info)
#define TASK_APPLY_OPTION_HELP
static int ada_task_is_alive(const struct ada_task_info *task_info)
static const char * get_long_state(unsigned value)
static void read_known_tasks()
static void info_task(struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
static void task_apply_all_command(const char *cmd, int from_tty)
static void ada_tasks_clear_pspace_data(program_space *pspace)
static bool read_known_tasks_array(struct ada_tasks_inferior_data *data)
void print_ada_task_info(struct ui_out *uiout, const char *arg_str, struct inferior *inf)
static void ada_tasks_invalidate_pspace_data(struct program_space *pspace)
static void ada_tasks_invalidate_inferior_data(struct inferior *inf)
static const char * get_state(unsigned value)
static struct ada_tasks_pspace_data * get_ada_tasks_pspace_data(struct program_space *pspace)
static void add_ada_task(CORE_ADDR task_id, struct inferior *inf)
static int ada_build_task_list()
const char * ada_get_tcb_types_info(void)
static void ada_task_list_changed(struct inferior *inf)
static void task_apply_command(const char *tidlist, int from_tty)
@ Master_Completion_Sleep
@ Interrupt_Server_Blocked_Interrupt_Sleep
@ Interrupt_Server_Blocked_On_Event_Flag
@ Interrupt_Server_Idle_Sleep
void iterate_over_live_ada_tasks(ada_task_list_iterator_ftype iterator)
static void ada_tasks_normal_stop_observer(struct bpstat *unused_args, int unused_args2)
static void ada_tasks_new_objfile_observer(objfile *objfile)
static struct ada_tasks_inferior_data * get_ada_tasks_inferior_data(struct inferior *inf)
static const int MAX_NUMBER_OF_KNOWN_TASKS
static void read_atcb(CORE_ADDR task_id, struct ada_task_info *task_info)
static ptid_t ptid_from_atcb_common(struct value *common_value)
static std::array< gdb::option::option_def_group, 1 > make_task_apply_all_options_def_group(qcs_flags *flags)
struct gdbarch * target_gdbarch(void)
ui_file_style style() const
const char * cur_tok() const
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
void field_fmt(const char *fldname, const char *format,...) ATTRIBUTE_PRINTF(3
void field_signed(const char *fldname, LONGEST value)
void field_skip(const char *fldname)
void text(const char *string)
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
bool is_mi_like_p() const
void message(const char *format,...) ATTRIBUTE_PRINTF(2
struct cmd_list_element * cmdlist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
cli_style_option metadata_style
void validate_flags_qcs(const char *which_command, qcs_flags *flags)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
struct value * parse_and_eval(const char *exp, parser_flags flags)
int frame_relative_level(frame_info_ptr fi)
frame_info_ptr get_selected_frame(const char *message)
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
bool switch_to_thread_if_alive(thread_info *thr)
void update_thread_list(void)
struct thread_info * inferior_thread(void)
void switch_to_thread(struct thread_info *thr)
void thread_try_catch_cmd(thread_info *thr, gdb::optional< int > ada_task, const char *cmd, int from_tty, const qcs_flags &flags)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
struct inferior * current_inferior(void)
all_inferiors_range all_inferiors(process_stratum_target *proc_target=nullptr)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
observable< struct objfile * > new_objfile
observable< program_space * > all_objfiles_removed
observable< struct bpstat *, int > normal_stop
bool process_options(const char **args, process_options_mode mode, gdb::array_view< const option_def_group > options_group)
@ PROCESS_OPTIONS_UNKNOWN_IS_OPERAND
std::string build_help(const char *help_tmpl, gdb::array_view< const option_def_group > options_group)
struct program_space * current_program_space
unsigned int known_tasks_length
CORE_ADDR known_tasks_addr
std::vector< ada_task_info > task_list
enum ada_known_tasks_kind known_tasks_kind
struct type * known_tasks_element
struct type * atcb_call_type
struct type * atcb_ll_type
unsigned int cpu_id_offset
struct type * atcb_common_type
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct type * builtin_data_ptr
struct type * builtin_uint32
LONGEST const_val() const
struct type * type() const
const char * linkage_name() const
struct program_space * pspace
struct type * type() const
CORE_ADDR value_address() const
struct type * target_type() const
struct field & field(int idx) const
range_bounds * bounds() const
type * index_type() const
gdb::array_view< const gdb_byte > contents()
struct type * type() const
struct block_symbol lookup_symbol_in_language(const char *name, const struct block *block, const domain_enum domain, enum language lang, struct field_of_this_result *is_a_field_of_this)
ptid_t target_get_ada_task_ptid(long lwp, ULONGEST tid)
void target_update_thread_list(void)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
struct value * value_subscript(struct value *array, LONGEST index)
struct value * value_at(struct type *type, CORE_ADDR addr)
struct value * value_ind(struct value *arg1)
struct value * value_field(struct value *arg1, int fieldno)
CORE_ADDR value_as_address(struct value *val)
LONGEST value_as_long(struct value *val)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address, frame_info_ptr frame)