--- Gnu-Mach/ddb/db_print.c 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/ddb/db_print.c 2020/09/02 04:50:31 1.1.1.5 @@ -2,24 +2,24 @@ * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -28,43 +28,46 @@ * Date: 7/90 */ -#include "mach_kdb.h" #if MACH_KDB /* * Miscellaneous printing. */ +#include #include -#include #include #include #include #include #include +#include #include #include +#include +#include #include #include #include #include +#include -extern unsigned int db_maxoff; +extern unsigned long db_maxoff; /* ARGSUSED */ void -db_show_regs(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char *modif; +db_show_regs( + db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + char *modif) { - register struct db_variable *regp; + struct db_variable *regp; db_expr_t value; db_addr_t offset; char * name; - register i; + int i; struct db_var_aux_param aux_param; task_t task = TASK_NULL; @@ -90,12 +93,12 @@ db_show_regs(addr, have_addr, count, mod aux_param.suffix[0] = i; db_read_write_variable(regp, &value, DB_VAR_GET, &aux_param); if (regp->max_level > 0) - db_printf("%s%d%*s", regp->name, i, + db_printf("%s%d%*s", regp->name, i, 12-strlen(regp->name)-((i<10)?1:2), ""); else db_printf("%-12s", regp->name); db_printf("%#*N", 2+2*sizeof(vm_offset_t), value); - db_find_xtrn_task_sym_and_offset((db_addr_t)value, &name, + db_find_xtrn_task_sym_and_offset((db_addr_t)value, &name, &offset, task); if (name != 0 && offset <= db_maxoff && offset != value) { db_printf("\t%s", name); @@ -116,7 +119,7 @@ db_show_regs(addr, have_addr, count, mod #ifndef DB_TASK_NAME #define DB_TASK_NAME(task) /* no task name */ #define DB_TASK_NAME_TITLE "" /* no task name */ -#endif DB_TASK_NAME +#endif /* DB_TASK_NAME */ #ifndef db_thread_fp_used #define db_thread_fp_used(thread) FALSE @@ -124,11 +127,11 @@ db_show_regs(addr, have_addr, count, mod char * db_thread_stat(thread, status) - register thread_t thread; - char *status; + const thread_t thread; + char *status; { - register char *p = status; - + char *p = status; + *p++ = (thread->state & TH_RUN) ? 'R' : '.'; *p++ = (thread->state & TH_WAIT) ? 'W' : '.'; *p++ = (thread->state & TH_SUSP) ? 'S' : '.'; @@ -141,10 +144,10 @@ db_thread_stat(thread, status) } void -db_print_thread(thread, thread_id, flag) - thread_t thread; - int thread_id; - int flag; +db_print_thread( + thread_t thread, + int thread_id, + int flag) { if (flag & OPTION_USER) { char status[8]; @@ -180,7 +183,7 @@ db_print_thread(thread, thread_id, flag) db_printf("\n "); } else db_printf(" "); - db_printf("%3d%c(%0*X,%s)", thread_id, + db_printf("%3d%c(%0*X,%s)", thread_id, (thread == current_thread())? '#': ':', 2*sizeof(vm_offset_t), thread, db_thread_stat(thread, status)); @@ -191,16 +194,12 @@ db_print_thread(thread, thread_id, flag) 2*sizeof(vm_offset_t), thread); else db_printf("(%0*X) ", 2*sizeof(vm_offset_t), thread); - db_printf("%c%c%c%c%c", - (thread->state & TH_RUN) ? 'R' : ' ', - (thread->state & TH_WAIT) ? 'W' : ' ', - (thread->state & TH_SUSP) ? 'S' : ' ', - (thread->state & TH_UNINT)? 'N' : ' ', - db_thread_fp_used(thread) ? 'F' : ' '); + char status[8]; + db_printf("%s", db_thread_stat(thread, status)); if (thread->state & TH_SWAPPED) { if (thread->swap_func) { db_printf("("); - db_task_printsym((db_addr_t)thread->swap_func, + db_task_printsym((db_addr_t)thread->swap_func, DB_STGY_ANY, kernel_task); db_printf(")"); } else { @@ -209,7 +208,7 @@ db_print_thread(thread, thread_id, flag) } if (thread->state & TH_WAIT) { db_printf(" "); - db_task_printsym((db_addr_t)thread->wait_event, + db_task_printsym((db_addr_t)thread->wait_event, DB_STGY_ANY, kernel_task); } db_printf("\n"); @@ -217,17 +216,17 @@ db_print_thread(thread, thread_id, flag) } void -db_print_task(task, task_id, flag) - task_t task; - int task_id; - int flag; +db_print_task( + task_t task, + int task_id, + int flag) { thread_t thread; int thread_id; if (flag & OPTION_USER) { if (flag & OPTION_TASK_TITLE) { - db_printf(" ID: TASK MAP THD SUS PR %s", + db_printf(" ID: TASK MAP THD SUS PR %s", DB_TASK_NAME_TITLE); if ((flag & OPTION_LONG) == 0) db_printf(" THREADS"); @@ -255,7 +254,12 @@ db_print_task(task, task_id, flag) } else { if (flag & OPTION_TASK_TITLE) db_printf(" TASK THREADS\n"); - db_printf("%3d (%0*X): ", task_id, 2*sizeof(vm_offset_t), task); + if (task->name[0]) + db_printf("%3d %s (%0*X): ", task_id, task->name, + 2*sizeof(vm_offset_t), task); + else + db_printf("%3d (%0*X): ", task_id, + 2*sizeof(vm_offset_t), task); if (task->thread_count == 0) { db_printf("no threads\n"); } else { @@ -272,13 +276,37 @@ db_print_task(task, task_id, flag) } } +void +db_show_all_tasks(db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + const char *modif) +{ + task_t task; + int task_id = 0; + processor_set_t pset; + + db_printf(" ID %-*s NAME [THREADS]\n", 2*sizeof(vm_offset_t), "TASK"); + + queue_iterate(&all_psets, pset, processor_set_t, all_psets) + queue_iterate(&pset->tasks, task, task_t, pset_tasks) { + db_printf("%3d %0*X %s [%d]\n", + task_id, + 2*sizeof(vm_offset_t), + task, + task->name, + task->thread_count); + task_id++; + } +} + /*ARGSUSED*/ void db_show_all_threads(addr, have_addr, count, modif) db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { task_t task; int task_id; @@ -329,7 +357,7 @@ db_show_one_thread(addr, have_addr, coun db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { int flag; int thread_id; @@ -375,7 +403,7 @@ db_show_one_task(addr, have_addr, count, db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { int flag; int task_id; @@ -407,41 +435,33 @@ db_show_one_task(addr, have_addr, count, int db_port_iterate(thread, func) - thread_t thread; + const thread_t thread; void (*func)(); { ipc_entry_t entry; - int index; int n = 0; - int size; - ipc_space_t space; - - space = thread->task->itk_space; - entry = space->is_table; - size = space->is_table_size; - for (index = 0; index < size; index++, entry++) { + struct rdxtree_iter iter; + rdxtree_for_each(&thread->task->itk_space->is_map, &iter, entry) { if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) - (*func)(index, (ipc_port_t) entry->ie_object, + (*func)(entry->ie_name, (ipc_port_t) entry->ie_object, entry->ie_bits, n++); } return(n); } ipc_port_t -db_lookup_port(thread, id) - thread_t thread; - int id; +db_lookup_port( + thread_t thread, + int id) { - register ipc_space_t space; - register ipc_entry_t entry; + ipc_entry_t entry; if (thread == THREAD_NULL) return(0); - space = thread->task->itk_space; - if (id < 0 || id >= space->is_table_size) + if (id < 0) return(0); - entry = &space->is_table[id]; - if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) + entry = ipc_entry_lookup(thread->task->itk_space, (mach_port_t) id); + if (entry && entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) return((ipc_port_t)entry->ie_object); return(0); } @@ -449,7 +469,7 @@ db_lookup_port(thread, id) static void db_print_port_id(id, port, bits, n) int id; - ipc_port_t port; + const ipc_port_t port; unsigned bits; int n; { @@ -463,7 +483,7 @@ db_print_port_id(id, port, bits, n) static void db_print_port_id_long( int id, - ipc_port_t port, + const ipc_port_t port, unsigned bits, int n) { @@ -481,7 +501,7 @@ db_show_port_id(addr, have_addr, count, db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { thread_t thread; @@ -508,4 +528,4 @@ db_show_port_id(addr, have_addr, count, db_printf("\n"); } -#endif MACH_KDB +#endif /* MACH_KDB */