*/
-#include <ctype.h>
-#include "defs.h"
-#include "command.h"
+#include <ctype.h>
+#include "defs.h"
+#include "command.h"
#include "value.h"
#include "language.h"
#include "inferior.h"
#include "symtab.h"
#include "target.h"
+#include "regcache.h"
#include "gdbcore.h"
#if (defined(__alpha__) && defined(__osf__) && !defined(__alpha_vxworks))
#if (defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET))
#include "gregset.h"
-#endif
+#endif
#include "ada-lang.h"
#elif defined (sun) && defined (__SVR4)
#define GET_CURRENT_THREAD solaris_thread_get_current_thread
#define THREAD_FETCH_REGISTERS() (-1)
-extern void *GET_CURRENT_THREAD();
+extern void *GET_CURRENT_THREAD ();
#elif defined (_AIX) || (defined(__alpha__) && defined(__osf__))
-extern void *GET_CURRENT_THREAD();
+extern void *GET_CURRENT_THREAD ();
#elif defined (__WIN32__) || defined (hpux)
#define GET_CURRENT_THREAD() (inferior_pid)
#define READ_MEMORY(addr, var) read_memory (addr, (char*) &var, sizeof (var))
/* external declarations */
-extern struct value* find_function_in_inferior (char *);
-
/* Global visible variables */
struct task_entry *task_list = NULL;
int current_task = -1, current_task_id = -1, current_task_index;
void *current_thread, *current_lwp;
-char *ada_task_states[] =
-{
+char *ada_task_states[] = {
"Unactivated",
"Runnable",
"Terminated",
/* Global internal types */
-static char *ada_long_task_states[] =
-{
+static char *ada_long_task_states[] = {
"Unactivated",
"Runnable",
"Terminated",
/* Global internal variables */
static int highest_task_num = 0;
-int thread_support = 0; /* 1 if the thread library in use is supported */
+int thread_support = 0; /* 1 if the thread library in use is supported */
static int gdbtk_task_initialization = 0;
-static int
+static int
add_task_entry (void *p_task_id, int index)
{
struct task_entry *new_task_entry = NULL;
pt->next_task = new_task_entry;
pt->stack_per = 0;
}
- else task_list = new_task_entry;
+ else
+ task_list = new_task_entry;
return new_task_entry->task_num;
}
-int
+int
get_entry_number (void *p_task_id)
{
struct task_entry *pt;
while (pt != NULL)
{
if (pt->thread == thread)
- return pt;
+ return pt;
pt = pt->next_task;
}
return 0;
void *
get_self_id (void)
{
- struct value* val;
+ struct value *val;
void *self_id;
int result;
struct task_entry *ent;
return NULL;
}
-int get_current_task ()
+int
+get_current_task (void)
{
int result;
-
+
/* FIXME: language_ada should be defined in defs.h */
/* if (current_language->la_language != language_ada) return -1; */
void *self_id, *caller;
struct task_fields atcb, atcb2;
struct entry_call call;
- int bounds [2];
- char image [256];
+ int bounds[2];
+ char image[256];
int num;
/* FIXME: language_ada should be defined in defs.h */
/* if (current_language->la_language != language_ada)
- {
- printf_filtered ("The current language does not support tasks.\n");
- return;
- }
- */
+ {
+ printf_filtered ("The current language does not support tasks.\n");
+ return;
+ }
+ */
pt = get_entry_vptr (atoi (arg));
if (pt == NULL)
{
- printf_filtered ("Task %s not found.\n", arg);
- return;
+ printf_filtered ("Task %s not found.\n", arg);
+ return;
}
temp_task = pt->task_id;
printf_filtered ("Ada Task: %p\n", temp_task);
/* print the name of the task */
- if (atcb.image.P_ARRAY != NULL) {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds);
- bounds [1] = EXTRACT_INT (bounds [1]);
- read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
- (char*) &image, bounds [1]);
- printf_filtered ("Name: %.*s\n", bounds [1], image);
- }
- else printf_filtered ("<no name>\n");
+ if (atcb.image.P_ARRAY != NULL)
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds);
+ bounds[1] = EXTRACT_INT (bounds[1]);
+ read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
+ (char *) &image, bounds[1]);
+ printf_filtered ("Name: %.*s\n", bounds[1], image);
+ }
+ else
+ printf_filtered ("<no name>\n");
/* print the thread id */
if ((long) pt->lwp != 0)
{
if ((long) pt->lwp < 65536)
- printf_filtered ("LWP: %ld\n", (long int) pt->lwp);
+ printf_filtered ("LWP: %ld\n", (long int) pt->lwp);
else
- printf_filtered ("LWP: %p\n", pt->lwp);
+ printf_filtered ("LWP: %p\n", pt->lwp);
}
/* print the parent gdb task id */
READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2);
/* print the name of the task */
- if (atcb2.image.P_ARRAY != NULL) {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
- bounds);
- bounds [1] = EXTRACT_INT (bounds [1]);
- read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
- (char*) &image, bounds [1]);
- printf_filtered (" (%.*s)\n", bounds [1], image);
- }
+ if (atcb2.image.P_ARRAY != NULL)
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
+ bounds);
+ bounds[1] = EXTRACT_INT (bounds[1]);
+ read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
+ (char *) &image, bounds[1]);
+ printf_filtered (" (%.*s)\n", bounds[1], image);
+ }
else
- printf_filtered ("\n");
+ printf_filtered ("\n");
}
else
printf_filtered ("No parent\n");
/* check if this task is accepting a rendezvous */
if (atcb.call == NULL)
caller = NULL;
- else {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
- caller = EXTRACT_ADDRESS (call.self);
- }
-
+ else
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
+ caller = EXTRACT_ADDRESS (call.self);
+ }
+
if (caller != NULL)
{
num = get_entry_number (caller);
READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2);
/* print the name of the task */
- if (atcb2.image.P_ARRAY != NULL) {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
- bounds);
- bounds [1] = EXTRACT_INT (bounds [1]);
- read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
- (char*) &image, bounds [1]);
- printf_filtered (" (%.*s)\n", bounds [1], image);
- }
+ if (atcb2.image.P_ARRAY != NULL)
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
+ bounds);
+ bounds[1] = EXTRACT_INT (bounds[1]);
+ read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
+ (char *) &image, bounds[1]);
+ printf_filtered (" (%.*s)\n", bounds[1], image);
+ }
else
printf_filtered ("\n");
}
printf_filtered ("\n");
}
else
- printf_filtered ("State: %s\n", ada_long_task_states [atcb.state]);
+ printf_filtered ("State: %s\n", ada_long_task_states[atcb.state]);
}
#if 0
print_align (void)
{
struct task_fields tf;
- void *tf_base = &(tf);
- void *tf_state = &(tf.state);
- void *tf_entry_num = &(tf.entry_num);
- void *tf_parent = &(tf.parent);
- void *tf_priority = &(tf.priority);
+ void *tf_base = &(tf);
+ void *tf_state = &(tf.state);
+ void *tf_entry_num = &(tf.entry_num);
+ void *tf_parent = &(tf.parent);
+ void *tf_priority = &(tf.priority);
void *tf_current_priority = &(tf.current_priority);
- void *tf_image = &(tf.image);
- void *tf_call = &(tf.call);
- void *tf_thread = &(tf.thread);
- void *tf_lwp = &(tf.lwp);
+ void *tf_image = &(tf.image);
+ void *tf_call = &(tf.call);
+ void *tf_thread = &(tf.thread);
+ void *tf_lwp = &(tf.lwp);
printf_filtered ("\n");
printf_filtered ("(tf_base = 0x%x)\n", tf_base);
- printf_filtered ("task_fields.entry_num at %3d (0x%x)\n", tf_entry_num - tf_base, tf_entry_num);
- printf_filtered ("task_fields.state at %3d (0x%x)\n", tf_state - tf_base, tf_state);
- printf_filtered ("task_fields.parent at %3d (0x%x)\n", tf_parent - tf_base, tf_parent);
- printf_filtered ("task_fields.priority at %3d (0x%x)\n", tf_priority - tf_base, tf_priority);
- printf_filtered ("task_fields.current_priority at %3d (0x%x)\n", tf_current_priority - tf_base, tf_current_priority);
- printf_filtered ("task_fields.image at %3d (0x%x)\n", tf_image - tf_base, tf_image);
- printf_filtered ("task_fields.call at %3d (0x%x)\n", tf_call - tf_base, tf_call);
- printf_filtered ("task_fields.thread at %3d (0x%x)\n", tf_thread - tf_base, tf_thread);
- printf_filtered ("task_fields.lwp at %3d (0x%x)\n", tf_lwp - tf_base, tf_lwp);
- printf_filtered ("\n");
+ printf_filtered ("task_fields.entry_num at %3d (0x%x)\n",
+ tf_entry_num - tf_base, tf_entry_num);
+ printf_filtered ("task_fields.state at %3d (0x%x)\n",
+ tf_state - tf_base, tf_state);
+ printf_filtered ("task_fields.parent at %3d (0x%x)\n",
+ tf_parent - tf_base, tf_parent);
+ printf_filtered ("task_fields.priority at %3d (0x%x)\n",
+ tf_priority - tf_base, tf_priority);
+ printf_filtered ("task_fields.current_priority at %3d (0x%x)\n",
+ tf_current_priority - tf_base, tf_current_priority);
+ printf_filtered ("task_fields.image at %3d (0x%x)\n",
+ tf_image - tf_base, tf_image);
+ printf_filtered ("task_fields.call at %3d (0x%x)\n",
+ tf_call - tf_base, tf_call);
+ printf_filtered ("task_fields.thread at %3d (0x%x)\n",
+ tf_thread - tf_base, tf_thread);
+ printf_filtered ("task_fields.lwp at %3d (0x%x)\n",
+ tf_lwp - tf_base, tf_lwp);
+ printf_filtered ("\n");
}
#endif
static void
info_tasks (char *arg, int from_tty)
{
- struct value* val;
+ struct value *val;
int i, task_number, state;
- void *temp_task, *temp_tasks [MAX_NUMBER_OF_KNOWN_TASKS];
+ void *temp_task, *temp_tasks[MAX_NUMBER_OF_KNOWN_TASKS];
struct task_entry *pt;
- void *self_id, *caller, *thread_id=NULL;
+ void *self_id, *caller, *thread_id = NULL;
struct task_fields atcb;
struct entry_call call;
- int bounds [2];
- char image [256];
+ int bounds[2];
+ char image[256];
int size;
char car;
task_number = 0;
- if (PIDGET(inferior_ptid) == 0)
+ if (PIDGET (inferior_ptid) == 0)
{
printf_filtered ("The program is not being run under gdb. ");
printf_filtered ("Use 'run' or 'attach' first.\n");
known_tasks_addr = (void *) SYMBOL_VALUE_ADDRESS (msym);
else
#ifndef VXWORKS_TARGET
- return;
+ return;
#else
{
if (target_lookup_symbol (KNOWN_TASKS_NAME, &known_tasks_addr) != 0)
READ_MEMORY ((CORE_ADDR) known_tasks_addr, temp_tasks);
- for (i=0; i<MAX_NUMBER_OF_KNOWN_TASKS; i++)
+ for (i = 0; i < MAX_NUMBER_OF_KNOWN_TASKS; i++)
{
temp_task = EXTRACT_ADDRESS (temp_tasks[i]);
if (temp_task != NULL)
- {
- task_number = get_entry_number (temp_task);
- if (task_number == 0)
+ {
+ task_number = get_entry_number (temp_task);
+ if (task_number == 0)
task_number = add_task_entry (temp_task, i);
- }
- }
+ }
+ }
/* Return without printing anything if this function was called in
order to init GDBTK tasking. */
- if (init_only) return;
+ if (init_only)
+ return;
/* print the header */
#if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET)
printf_filtered
- (" ID TID P-ID Pri Stack %% State Name\n");
+ (" ID TID P-ID Pri Stack %% State Name\n");
#else
printf_filtered (" ID TID P-ID Pri State Name\n");
#endif
printf_filtered (" %9lx", (long) temp_task);
#else
#ifdef TARGET_64
- printf_filtered (" %#9lx", (unsigned long)pt->thread & 0x3ffffffffff);
+ printf_filtered (" %#9lx", (unsigned long) pt->thread & 0x3ffffffffff);
#else
- printf_filtered (" %#9lx", (long)pt->thread);
+ printf_filtered (" %#9lx", (long) pt->thread);
#endif
#endif
/* print the parent gdb task id */
printf_filtered
- (" %4d", get_entry_number (EXTRACT_ADDRESS (atcb.parent)));
+ (" %4d", get_entry_number (EXTRACT_ADDRESS (atcb.parent)));
/* print the base priority of the task */
printf_filtered (" %3d", EXTRACT_INT (atcb.priority));
#if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET)
if (pt->task_num == 1 || atcb.state == Terminated)
{
- printf_filtered (" Unknown");
+ printf_filtered (" Unknown");
goto next;
}
- read_memory ((CORE_ADDR)atcb.thread, &thr, sizeof (thr));
+ read_memory ((CORE_ADDR) atcb.thread, &thr, sizeof (thr));
current_thread = atcb.thread;
- regs.regs [SP_REGNUM] = 0;
- if (dec_thread_get_registers (®s, NULL) == 0) {
- pt->stack_per = (100 * ((long)thr.__stack_base -
- regs.regs [SP_REGNUM])) / thr.__stack_size;
- /* if the thread is terminated but still there, the
- stack_base/size values are erroneous. Try to patch it */
- if (pt->stack_per < 0 || pt->stack_per > 100) pt->stack_per = 0;
- }
+ regs.regs[SP_REGNUM] = 0;
+ if (dec_thread_get_registers (®s, NULL) == 0)
+ {
+ pt->stack_per = (100 * ((long) thr.__stack_base -
+ regs.regs[SP_REGNUM])) / thr.__stack_size;
+ /* if the thread is terminated but still there, the
+ stack_base/size values are erroneous. Try to patch it */
+ if (pt->stack_per < 0 || pt->stack_per > 100)
+ pt->stack_per = 0;
+ }
/* print information about stack space used in the thread */
- if (thr.__stack_size < 1024*1024)
+ if (thr.__stack_size < 1024 * 1024)
{
size = thr.__stack_size / 1024;
car = 'K';
}
- else if (thr.__stack_size < 1024*1024*1024)
+ else if (thr.__stack_size < 1024 * 1024 * 1024)
{
size = thr.__stack_size / 1024 / 1024;
car = 'M';
}
- else /* Who knows... */
+ else /* Who knows... */
{
size = thr.__stack_size / 1024 / 1024 / 1024;
car = 'G';
}
printf_filtered (" %4d%c %2d", size, car, pt->stack_per);
-next:
+ next:
#endif
/* print the current state of the task */
/* check if this task is accepting a rendezvous */
if (atcb.call == NULL)
caller = NULL;
- else {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
- caller = EXTRACT_ADDRESS (call.self);
- }
-
+ else
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
+ caller = EXTRACT_ADDRESS (call.self);
+ }
+
if (caller != NULL)
- printf_filtered (" Accepting RV with %-4d", get_entry_number (caller));
+ printf_filtered (" Accepting RV with %-4d",
+ get_entry_number (caller));
else
{
state = atcb.state;
/* Replace "Runnable" by "Running" if this is the current task */
printf_filtered (" %-22s", "Running");
else
- printf_filtered (" %-22s", ada_task_states [state]);
+ printf_filtered (" %-22s", ada_task_states[state]);
}
/* finally, print the name of the task */
- if (atcb.image.P_ARRAY != NULL) {
- READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds);
- bounds [1] = EXTRACT_INT (bounds [1]);
- read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
- (char*)&image, bounds [1]);
- printf_filtered (" %.*s\n", bounds [1], image);
- }
- else printf_filtered (" <no name>\n");
+ if (atcb.image.P_ARRAY != NULL)
+ {
+ READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS),
+ bounds);
+ bounds[1] = EXTRACT_INT (bounds[1]);
+ read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
+ (char *) &image, bounds[1]);
+ printf_filtered (" %.*s\n", bounds[1], image);
+ }
+ else
+ printf_filtered (" <no name>\n");
pt = pt->next_task;
}
static void
info_tasks_command (char *arg, int from_tty)
{
- if (arg == NULL || *arg == '\000')
- info_tasks (arg, from_tty);
- else
- info_task (arg, from_tty);
+ if (arg == NULL || *arg == '\000')
+ info_tasks (arg, from_tty);
+ else
+ info_task (arg, from_tty);
}
/* Switch from one thread to another. */
#endif
}
- if (res == 0) stop_pc = read_pc();
+ if (res == 0)
+ stop_pc = read_pc ();
select_frame (get_current_frame ());
return res;
}
if (!tidstr)
error ("Please specify a task ID. Use the \"info tasks\" command to\n"
- "see the IDs of currently known tasks.");
+ "see the IDs of currently known tasks.");
num = atoi (tidstr);
e = get_entry_vptr (num);
if (e == NULL)
error ("Task ID %d not known. Use the \"info tasks\" command to\n"
- "see the IDs of currently known tasks.", num);
+ "see the IDs of currently known tasks.", num);
if (current_task_id == -1)
{
if (task_switch (e->thread, e->lwp) == 0)
{
/* FIXME: find_printable_frame should be defined in frame.h, and
- implemented in ada-lang.c */
- /* find_printable_frame (selected_frame, frame_relative_level (selected_frame));*/
+ implemented in ada-lang.c */
+ /* find_printable_frame (deprecated_selected_frame, frame_relative_level (deprecated_selected_frame)); */
printf_filtered ("[Switching to task %d]\n", num);
- print_stack_frame (selected_frame, frame_relative_level (selected_frame), 1);
+ print_stack_frame (deprecated_selected_frame,
+ frame_relative_level (deprecated_selected_frame), 1);
}
else
printf_filtered ("Unable to switch to task %d\n", num);
static struct cmd_list_element *task_cmd_list = NULL;
extern struct cmd_list_element *cmdlist;
- add_info (
- "tasks", info_tasks_command,
- "Without argument: list all known Ada tasks, with status information.\n"
- "info tasks n: print detailed information of task n.\n");
+ add_info ("tasks", info_tasks_command,
+ "Without argument: list all known Ada tasks, with status information.\n"
+ "info tasks n: print detailed information of task n.\n");
add_prefix_cmd ("task", class_run, task_command,
- "Use this command to switch between tasks.\n\
- The new task ID must be currently known.", &task_cmd_list, "task ", 1,
- &cmdlist);
+ "Use this command to switch between tasks.\n\
+ The new task ID must be currently known.", &task_cmd_list, "task ", 1, &cmdlist);
}