/* * Examine (print) data. */ void db_examine_cmd( db_expr_t addr, int have_addr, db_expr_t count, char * modif) { thread_act_t thr_act; extern char db_last_modifier[]; if (modif[0] != '\0') strcpy(db_examine_format, modif); if (count == -1) count = 1; db_examine_count = count; if (db_option(modif, 't')) { if (modif == db_last_modifier) thr_act = db_examine_act; else if (!db_get_next_act(&thr_act, 0)) return; } else if (db_option(modif,'u')) thr_act = current_act(); else thr_act = THR_ACT_NULL; db_examine_act = thr_act; db_examine((db_addr_t) addr, db_examine_format, count, db_act_to_task(thr_act)); }
void db_breakpoint_cmd( db_expr_t addr, int have_addr, db_expr_t count, char * modif) { register int n; thread_act_t thr_act; boolean_t user_global = db_option(modif, 'U'); boolean_t task_bpt = db_option(modif, 'T'); boolean_t user_space; if (count == -1) count = 1; if (task_bpt && user_global) db_error("Cannot specify both 'T' and 'U'\n"); user_space = (user_global)? TRUE: db_option(modif, 'u'); if (user_space && db_access_level < DB_ACCESS_CURRENT) db_error("User space break point is not supported\n"); if ((!task_bpt || !user_space) && !DB_VALID_ADDRESS(addr, user_space)) { /* if the user has explicitly specified user space, do not insert a breakpoint into the kernel */ if (user_space) db_error("Invalid user space address\n"); user_space = TRUE; db_printf("%#X is in user space\n", addr); db_printf("kernel is from %#X to %#x\n", VM_MIN_KERNEL_ADDRESS, VM_MAX_KERNEL_ADDRESS); } if (db_option(modif, 't') || task_bpt) { for (n = 0; db_get_next_act(&thr_act, n); n++) { if (thr_act == THR_ACT_NULL) db_error("No active thr_act\n"); if (task_bpt && thr_act->task == TASK_NULL) db_error("No task\n"); if (db_access_level <= DB_ACCESS_CURRENT && user_space && thr_act->task != db_current_space()) db_error("Cannot set break point in inactive user space\n"); db_set_breakpoint(db_target_space(thr_act, user_space), (db_addr_t)addr, count, (user_global)? THR_ACT_NULL: thr_act, task_bpt); } } else { db_set_breakpoint(db_target_space(THR_ACT_NULL, user_space), (db_addr_t)addr, count, THR_ACT_NULL, FALSE); } }
long db_i386_reg_value( struct db_variable *vp, db_expr_t *valuep, int flag, db_var_aux_param_t ap) { long *dp = 0; db_expr_t null_reg = 0; register thread_t thread = ap->thread; extern unsigned int_stack_high; if (db_option(ap->modif, 'u')) { if (thread == THREAD_NULL) { if ((thread = current_thread()) == THREAD_NULL) db_error("no user registers\n"); } if (thread == current_thread()) { if (ddb_regs.cs & 0x3) dp = vp->valuep; else if (ddb_regs.ebp < int_stack_high) db_error("cannot get/set user registers in nested interrupt\n"); } } else { if (thread == THREAD_NULL || thread == current_thread()) { dp = vp->valuep; } else if ((thread->state & TH_SWAPPED) == 0 && thread->kernel_stack) { dp = db_lookup_i386_kreg(vp->name, (long *)(STACK_IKS(thread->kernel_stack))); if (dp == 0) dp = &null_reg; } else if ((thread->state & TH_SWAPPED) && thread->swap_func != thread_exception_return) { /*.....this breaks t/t $taskN.0...*/ /* only EIP is valid */ if (vp->valuep == (long *) &ddb_regs.eip) { dp = (long *)(&thread->swap_func); } else { dp = &null_reg; } } } if (dp == 0) { if (thread->pcb == 0) db_error("no pcb\n"); dp = (long *)((long)(&thread->pcb->iss) + ((long)vp->valuep - (long)&ddb_regs)); } if (flag == DB_VAR_SET) *dp = *valuep; else *valuep = *dp; }
/* Delete breakpoint */ void db_delete_cmd(void) { register int n; thread_act_t thr_act; vm_offset_t task_thd; boolean_t user_global = FALSE; boolean_t task_bpt = FALSE; boolean_t user_space = FALSE; boolean_t thd_bpt = FALSE; db_expr_t addr; int t; t = db_read_token(); if (t == tSLASH) { t = db_read_token(); if (t != tIDENT) { db_printf("Bad modifier \"%s\"\n", db_tok_string); db_error(0); } user_global = db_option(db_tok_string, 'U'); user_space = (user_global)? TRUE: db_option(db_tok_string, 'u'); task_bpt = db_option(db_tok_string, 'T'); thd_bpt = db_option(db_tok_string, 't'); if (task_bpt && user_global) db_error("Cannot specify both 'T' and 'U' option\n"); t = db_read_token(); } if ( t == tSTAR ) { db_printf("Delete ALL breakpoints\n"); db_delete_all_breakpoints( (task_t)task_bpt ); return; } if (t == tHASH) { db_thread_breakpoint_t tbp; db_breakpoint_t bkpt; if (db_read_token() != tNUMBER) { db_printf("Bad break point number #%s\n", db_tok_string); db_error(0); } if ((tbp = db_find_breakpoint_number(db_tok_number, &bkpt)) == 0) { db_printf("No such break point #%d\n", db_tok_number); db_error(0); } db_delete_breakpoint(bkpt->task, bkpt->address, tbp->tb_task_thd); return; } db_unread_token(t); if (!db_expression(&addr)) { /* * We attempt to pick up the user_space indication from db_dot, * so that a plain "d" always works. */ addr = (db_expr_t)db_dot; if (!user_space && !DB_VALID_ADDRESS(addr, FALSE)) user_space = TRUE; } if (!DB_VALID_ADDRESS(addr, user_space)) { db_printf("Address %#X is not in %s space\n", addr, (user_space)? "user": "******"); db_error(0); } if (thd_bpt || task_bpt) { for (n = 0; db_get_next_act(&thr_act, n); n++) { if (thr_act == THR_ACT_NULL) db_error("No active thr_act\n"); if (task_bpt) { if (thr_act->task == TASK_NULL) db_error("No task\n"); task_thd = (vm_offset_t) (thr_act->task); } else task_thd = (user_global)? 0: (vm_offset_t) thr_act; db_delete_breakpoint(db_target_space(thr_act, user_space), (db_addr_t)addr, task_thd); } } else { db_delete_breakpoint(db_target_space(THR_ACT_NULL, user_space), (db_addr_t)addr, 0); } }
void ipc_port_print( ipc_port_t port, __unused boolean_t have_addr, __unused db_expr_t count, char *modif) { db_addr_t task; int task_id; int nmsgs; int verbose = 0; #if MACH_ASSERT int i, needs_db_indent, items_printed; #endif /* MACH_ASSERT */ if (db_option(modif, 'l') || db_option(modif, 'v')) ++verbose; printf("port 0x%x\n", port); db_indent += 2; ipc_object_print(&port->ip_object); if (ipc_port_print_long) { printf("\n"); } if (!ip_active(port)) { iprintf("timestamp=0x%x", port->ip_timestamp); } else if (port->ip_receiver_name == MACH_PORT_NULL) { iprintf("destination=0x%x (", port->ip_destination); if (port->ip_destination != MACH_PORT_NULL && (task = db_task_from_space(port->ip_destination-> ip_receiver, &task_id))) printf("task%d at 0x%x", task_id, task); else printf("unknown"); printf(")"); } else { iprintf("receiver=0x%x (", port->ip_receiver); if (port->ip_receiver == ipc_space_kernel) printf("kernel"); else if (port->ip_receiver == ipc_space_reply) printf("reply"); else if (port->ip_receiver == default_pager_space) printf("default_pager"); else if ((task = db_task_from_space(port->ip_receiver, &task_id)) != (db_addr_t)0) printf("task%d at 0x%x", task_id, task); else printf("unknown"); printf(")"); } printf(", receiver_name=0x%x\n", port->ip_receiver_name); iprintf("mscount=%d", port->ip_mscount); printf(", srights=%d", port->ip_srights); printf(", sorights=%d\n", port->ip_sorights); iprintf("nsrequest=0x%x", port->ip_nsrequest); printf(", pdrequest=0x%x", port->ip_pdrequest); printf(", dnrequests=0x%x\n", port->ip_dnrequests); iprintf("pset_count=0x%x", port->ip_pset_count); printf(", seqno=%d", port->ip_messages.imq_seqno); printf(", msgcount=%d", port->ip_messages.imq_msgcount); printf(", qlimit=%d\n", port->ip_messages.imq_qlimit); iprintf("kmsgs=0x%x", port->ip_messages.imq_messages.ikmq_base); printf(", rcvrs queue=0x%x", port->ip_messages.imq_wait_queue); printf(", kobj=0x%x\n", port->ip_kobject); iprintf("premsg=0x%x", port->ip_premsg); #if MACH_ASSERT /* don't bother printing callstack or queue links */ iprintf("ip_thread=0x%x, ip_timetrack=0x%x\n", port->ip_thread, port->ip_timetrack); items_printed = 0; needs_db_indent = 1; for (i = 0; i < IP_NSPARES; ++i) { if (port->ip_spares[i] != 0) { if (needs_db_indent) { iprintf(""); needs_db_indent = 0; } printf("%sip_spares[%d] = %d", items_printed ? ", " : "", i, port->ip_spares[i]); if (++items_printed >= 4) { needs_db_indent = 1; printf("\n"); items_printed = 0; } } } #endif /* MACH_ASSERT */ if (verbose) { iprintf("kmsg queue contents:\n"); db_indent += 2; nmsgs = db_port_queue_print(port); db_indent -= 2; iprintf("...total kmsgs: %d\n", nmsgs); } db_indent -=2; }
void db_print_cmd(void) { db_expr_t value; int t; task_t task = TASK_NULL; if ((t = db_read_token()) == tSLASH) { if (db_read_token() != tIDENT) { db_printf("Bad modifier \"/%s\"\n", db_tok_string); db_error(0); /* NOTREACHED */ } if (db_tok_string[0]) db_print_format = db_tok_string[0]; if (db_option(db_tok_string, 't')) { if (db_default_act) task = db_default_act->task; if (db_print_format == 't') db_print_format = db_tok_string[1]; } } else db_unread_token(t); for ( ; ; ) { t = db_read_token(); if (t == tSTRING) { db_printf("%s", db_tok_string); continue; } db_unread_token(t); if (!db_expression(&value)) break; switch (db_print_format) { case 'a': case 'A': db_task_printsym((db_addr_t)value, (db_print_format == 'a') ? DB_STGY_ANY: DB_STGY_PROC, task); break; case 'r': db_printf("%11r", value); break; case 'x': db_printf("%08x", value); break; case 'z': db_printf("%8z", value); break; case 'd': db_printf("%11d", value); break; case 'u': db_printf("%11u", value); break; case 'o': db_printf("%16o", value); break; case 'c': value = value & 0xFF; if (value >= ' ' && value <= '~') db_printf("%c", value); else db_printf("\\%03o", value); break; default: db_printf("Unknown format %c\n", db_print_format); db_print_format = 'x'; db_error(0); } } }