Date: Wed, 12 Jul 2006 13:34:50 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 101373 for review Message-ID: <200607121334.k6CDYoqd037498@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=101373 Change 101373 by jhb@jhb_mutex on 2006/07/12 13:34:27 Convert db commands to use new pager interface. Non-normal changes include: - 'show idt' on i386 and pc98 didn't actually check the quit flag, now it does. - 'show intr' didn't actually check the quit flag either, but now it does. - 'show ktr' with the 'a' modifier has to disable the implicit paging via a layering violation now to preserve it's semantics. - sparc64 stack trace functions no longer have to pass quit pointers around since db_utrace() can just check db_pager_quit directly. Affected files ... .. //depot/projects/smpng/sys/amd64/amd64/db_trace.c#18 edit .. //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#17 edit .. //depot/projects/smpng/sys/amd64/amd64/local_apic.c#22 edit .. //depot/projects/smpng/sys/arm/arm/db_trace.c#14 edit .. //depot/projects/smpng/sys/ddb/db_command.c#30 edit .. //depot/projects/smpng/sys/ddb/db_ps.c#33 edit .. //depot/projects/smpng/sys/ddb/db_thread.c#7 edit .. //depot/projects/smpng/sys/dev/pci/pci.c#71 edit .. //depot/projects/smpng/sys/i386/i386/db_trace.c#30 edit .. //depot/projects/smpng/sys/i386/i386/intr_machdep.c#18 edit .. //depot/projects/smpng/sys/i386/i386/local_apic.c#43 edit .. //depot/projects/smpng/sys/i386/i386/machdep.c#108 edit .. //depot/projects/smpng/sys/ia64/ia64/db_machdep.c#2 edit .. //depot/projects/smpng/sys/kern/kern_intr.c#77 edit .. //depot/projects/smpng/sys/kern/kern_ktr.c#34 edit .. //depot/projects/smpng/sys/kern/subr_prf.c#45 edit .. //depot/projects/smpng/sys/pc98/pc98/machdep.c#14 edit .. //depot/projects/smpng/sys/powerpc/powerpc/db_trace.c#15 edit .. //depot/projects/smpng/sys/sparc64/sparc64/db_trace.c#26 edit Differences ... ==== //depot/projects/smpng/sys/amd64/amd64/db_trace.c#18 (text+ko) ==== @@ -390,16 +390,14 @@ long *argp; db_expr_t offset; c_db_sym_t sym; - int narg, quit; + int narg; boolean_t first; if (count == -1) count = 1024; first = TRUE; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (count-- && !quit) { + while (count-- && !db_pager_quit) { sym = db_search_symbol(pc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); ==== //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#17 (text+ko) ==== @@ -338,16 +338,14 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) { struct intsrc **isrc; - int i, quit, verbose; + int i, verbose; - quit = 0; if (strcmp(modif, "v") == 0) verbose = 1; else verbose = 0; isrc = interrupt_sources; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++) + for (i = 0; i < NUM_IO_INTS && !db_pager_quit; i++, isrc++) if (*isrc != NULL) db_dump_intr_event((*isrc)->is_event, verbose); } ==== //depot/projects/smpng/sys/amd64/amd64/local_apic.c#22 (text+ko) ==== @@ -755,18 +755,16 @@ DB_SHOW_COMMAND(apic, db_show_apic) { struct intsrc *isrc; - int quit, i, verbose; + int i, verbose; u_int irq; - quit = 0; if (strcmp(modif, "vv") == 0) verbose = 2; else if (strcmp(modif, "v") == 0) verbose = 1; else verbose = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (i = 0; i < APIC_NUM_IOINTS + 1 && !quit; i++) { + for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { irq = ioint_irqs[i]; if (irq != 0 && irq != IRQ_SYSCALL) { db_printf("vec 0x%2x -> ", i + APIC_IO_INTS); ==== //depot/projects/smpng/sys/arm/arm/db_trace.c#14 (text+ko) ==== @@ -93,15 +93,13 @@ db_expr_t value; db_expr_t offset; boolean_t kernel_only = TRUE; - int scp_offset, quit; + int scp_offset; frame = (u_int32_t *)addr; lastframe = NULL; scp_offset = -(get_pc_str_offset() >> 2); - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (count-- && frame != NULL && !quit) { + while (count-- && frame != NULL && !db_pager_quit) { db_addr_t scp; u_int32_t savecode; int r; ==== //depot/projects/smpng/sys/ddb/db_command.c#30 (text+ko) ==== @@ -676,16 +676,13 @@ { struct proc *p; struct thread *td; - int quit; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); LIST_FOREACH(p, &allproc, p_list) { FOREACH_THREAD_IN_PROC(p, td) { db_printf("\nTracing command %s pid %d tid %ld td %p\n", p->p_comm, p->p_pid, (long)td->td_tid, td); db_trace_thread(td, -1); - if (quit) + if (db_trace_quit) return; } } ==== //depot/projects/smpng/sys/ddb/db_ps.c#33 (text+ko) ==== @@ -73,23 +73,21 @@ struct ucred *cred; struct pgrp *pgrp; char state[9]; - int np, quit, rflag, sflag, dflag, lflag, wflag; + int np, rflag, sflag, dflag, lflag, wflag; np = nprocs; - quit = 0; if (!LIST_EMPTY(&allproc)) p = LIST_FIRST(&allproc); else p = &proc0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); #ifdef __LP64__ db_printf(" pid uid ppid pgrp state wmesg wchan cmd\n"); #else db_printf(" pid uid ppid pgrp state wmesg wchan cmd\n"); #endif - while (--np >= 0 && !quit) { + while (--np >= 0 && !db_pager_quit) { if (p == NULL) { db_printf("oops, ran out of processes early!\n"); break; @@ -191,7 +189,7 @@ #endif FOREACH_THREAD_IN_PROC(p, td) { dumpthread(p, td, p->p_flag & P_HADTHREADS); - if (quit) + if (db_pager_quit) break; } @@ -363,7 +361,7 @@ { struct thread *td; struct proc *p; - int i, quit; + int i; /* Determine which process to examine. */ if (have_addr) @@ -371,8 +369,6 @@ else p = kdb_thread->td_proc; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); db_printf("Process %d (%s) at %p:\n", p->p_pid, p->p_comm, p); db_printf(" state: "); switch (p->p_state) { @@ -411,7 +407,7 @@ db_printf(" threads: %d\n", p->p_numthreads); FOREACH_THREAD_IN_PROC(p, td) { dumpthread(p, td, 1); - if (quit) + if (db_pager_quit) break; } } ==== //depot/projects/smpng/sys/ddb/db_thread.c#7 (text+ko) ==== @@ -93,13 +93,9 @@ jmp_buf jb; void *prev_jb; struct thread *thr; - int pager_quit; - - db_setup_paging(db_simple_pager, &pager_quit, db_lines_per_page); - pager_quit = 0; thr = kdb_thr_first(); - while (!pager_quit && thr != NULL) { + while (!db_pager_quit && thr != NULL) { db_printf(" %6ld (%p) ", (long)thr->td_tid, thr); prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { ==== //depot/projects/smpng/sys/dev/pci/pci.c#71 (text+ko) ==== @@ -1716,7 +1716,7 @@ struct devlist *devlist_head; struct pci_conf *p; const char *name; - int i, error, none_count, quit; + int i, error, none_count; none_count = 0; /* get the head of the device queue */ @@ -1725,10 +1725,9 @@ /* * Go through the list of devices and print out devices */ - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (error = 0, i = 0, quit = 0, + for (error = 0, i = 0, dinfo = STAILQ_FIRST(devlist_head); - (dinfo != NULL) && (error == 0) && (i < pci_numdevs) && !quit; + (dinfo != NULL) && (error == 0) && (i < pci_numdevs) && !db_pager_quit; dinfo = STAILQ_NEXT(dinfo, pci_links), i++) { /* Populate pd_name and pd_unit */ ==== //depot/projects/smpng/sys/i386/i386/db_trace.c#30 (text+ko) ==== @@ -401,7 +401,7 @@ int *argp; db_expr_t offset; c_db_sym_t sym; - int instr, narg, quit; + int instr, narg; boolean_t first; /* @@ -432,9 +432,7 @@ count = 1024; first = TRUE; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (count-- && !quit) { + while (count-- && !db_pager_quit) { sym = db_search_symbol(pc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); ==== //depot/projects/smpng/sys/i386/i386/intr_machdep.c#18 (text+ko) ==== @@ -338,16 +338,14 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) { struct intsrc **isrc; - int i, quit, verbose; + int i, verbose; - quit = 0; if (strcmp(modif, "v") == 0) verbose = 1; else verbose = 0; isrc = interrupt_sources; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++) + for (i = 0; i < NUM_IO_INTS && !db_pager_quit; i++, isrc++) if (*isrc != NULL) db_dump_intr_event((*isrc)->is_event, verbose); } ==== //depot/projects/smpng/sys/i386/i386/local_apic.c#43 (text+ko) ==== @@ -758,18 +758,16 @@ DB_SHOW_COMMAND(apic, db_show_apic) { struct intsrc *isrc; - int quit, i, verbose; + int i, verbose; u_int irq; - quit = 0; if (strcmp(modif, "vv") == 0) verbose = 2; else if (strcmp(modif, "v") == 0) verbose = 1; else verbose = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (i = 0; i < APIC_NUM_IOINTS + 1 && !quit; i++) { + for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) { irq = ioint_irqs[i]; if (irq != 0 && irq != IRQ_SYSCALL) { db_printf("vec 0x%2x -> ", i + APIC_IO_INTS); ==== //depot/projects/smpng/sys/i386/i386/machdep.c#108 (text+ko) ==== @@ -1584,12 +1584,11 @@ DB_SHOW_COMMAND(idt, db_show_idt) { struct gate_descriptor *ip; - int idx, quit; + int idx; uintptr_t func; ip = idt; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (idx = 0, quit = 0; idx < NIDT; idx++) { + for (idx = 0; idx < NIDT && !db_pager_quit; idx++) { func = (ip->gd_hioffset << 16 | ip->gd_looffset); if (func != (uintptr_t)&IDTVEC(rsvd)) { db_printf("%3d\t", idx); ==== //depot/projects/smpng/sys/ia64/ia64/db_machdep.c#2 (text+ko) ==== @@ -228,12 +228,10 @@ db_expr_t offset; uint64_t bsp, cfm, ip, pfs, reg, sp; c_db_sym_t sym; - int args, error, i, quit; + int args, error, i; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); error = unw_create_from_pcb(&rs, pcb); - while (!error && count-- && !quit) { + while (!error && count-- && !db_pager_quit) { error = unw_get_cfm(&rs, &cfm); if (!error) error = unw_get_bsp(&rs, &bsp); ==== //depot/projects/smpng/sys/kern/kern_intr.c#77 (text+ko) ==== @@ -905,16 +905,16 @@ DB_SHOW_COMMAND(intr, db_show_intr) { struct intr_event *ie; - int quit, all, verbose; + int all, verbose; - quit = 0; verbose = index(modif, 'v') != NULL; all = index(modif, 'a') != NULL; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); TAILQ_FOREACH(ie, &event_list, ie_list) { if (!all && TAILQ_EMPTY(&ie->ie_handlers)) continue; db_dump_intr_event(ie, verbose); + if (db_pager_quit) + break; } } #endif /* DDB */ @@ -976,11 +976,9 @@ { u_long *i; char *cp; - int quit; cp = intrnames; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (i = intrcnt, quit = 0; i != eintrcnt && !quit; i++) { + for (i = intrcnt; i != eintrcnt && !db_pager_quit; i++) { if (*cp == '\0') break; if (*i != 0) ==== //depot/projects/smpng/sys/kern/kern_ktr.c#34 (text+ko) ==== @@ -55,8 +55,10 @@ #include <machine/ktr.h> #endif - +#ifdef DDB #include <ddb/ddb.h> +#include <ddb/db_output.h> +#endif #ifndef KTR_ENTRIES #define KTR_ENTRIES 1024 @@ -288,22 +290,17 @@ DB_SHOW_COMMAND(ktr, db_ktr_all) { - int quit; - quit = 0; tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1); tstate.first = -1; - if (strcmp(modif, "v") == 0) - db_ktr_verbose = 1; - else - db_ktr_verbose = 0; - if (strcmp(modif, "a") == 0) { + db_ktr_verbose = index(modif, 'v') != NULL; + if (index(modif, 'a') != NULL) { + db_disable_pager(); while (cncheckc() != -1) if (db_mach_vtrace() == 0) break; } else { - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (!quit) + while (!db_pager_quit) if (db_mach_vtrace() == 0) break; } ==== //depot/projects/smpng/sys/kern/subr_prf.c#45 (text+ko) ==== @@ -912,20 +912,17 @@ DB_SHOW_COMMAND(msgbuf, db_show_msgbuf) { - int i, j, quit; - - quit = 0; + int i, j; if (!msgbufmapped) { db_printf("msgbuf not mapped yet\n"); return; } - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); db_printf("msgbufp = %p\n", msgbufp); db_printf("magic = %x, size = %d, r= %u, w = %u, ptr = %p, cksum= %u\n", msgbufp->msg_magic, msgbufp->msg_size, msgbufp->msg_rseq, msgbufp->msg_wseq, msgbufp->msg_ptr, msgbufp->msg_cksum); - for (i = 0; i < msgbufp->msg_size && !quit; i++) { + for (i = 0; i < msgbufp->msg_size && !db_pager_quit; i++) { j = MSGBUF_SEQ_TO_POS(msgbufp, i + msgbufp->msg_rseq); db_printf("%c", msgbufp->msg_ptr[j]); } ==== //depot/projects/smpng/sys/pc98/pc98/machdep.c#14 (text+ko) ==== @@ -1581,12 +1581,11 @@ DB_SHOW_COMMAND(idt, db_show_idt) { struct gate_descriptor *ip; - int idx, quit; + int idx; uintptr_t func; ip = idt; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - for (idx = 0, quit = 0; idx < NIDT; idx++) { + for (idx = 0; idx < NIDT && !db_pager_quit; idx++) { func = (ip->gd_hioffset << 16 | ip->gd_looffset); if (func != (uintptr_t)&IDTVEC(rsvd)) { db_printf("%3d\t", idx); ==== //depot/projects/smpng/sys/powerpc/powerpc/db_trace.c#15 (text+ko) ==== @@ -131,7 +131,6 @@ const char *symname; boolean_t kernel_only = TRUE; boolean_t full = FALSE; - int quit; #if 0 { @@ -151,9 +150,7 @@ stackframe = fp; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (!quit) { + while (!db_pager_quit) { if (stackframe < PAGE_SIZE) break; ==== //depot/projects/smpng/sys/sparc64/sparc64/db_trace.c#26 (text+ko) ==== @@ -103,7 +103,7 @@ * User stack trace (debugging aid). */ static void -db_utrace(struct thread *td, struct trapframe *tf, int count, int *quitp) +db_utrace(struct thread *td, struct trapframe *tf, int count) { struct pcb *pcb; db_addr_t sp, rsp, o7, pc; @@ -115,7 +115,7 @@ FALSE); pc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); db_printf("user trace: trap %%o7=%#lx\n", o7); - while (count-- && sp != 0 && !*quitp) { + while (count-- && sp != 0 && !db_pager_quit) { db_printf("pc %#lx, sp %#lx\n", pc, sp); /* First, check whether the frame is in the pcb. */ found = 0; @@ -141,7 +141,7 @@ } static int -db_print_trap(struct thread *td, struct trapframe *tf, int count, int *quitp) +db_print_trap(struct thread *td, struct trapframe *tf, int count) { struct proc *p; const char *symname; @@ -219,7 +219,7 @@ db_printf("userland() at "); db_printsym(tpc, DB_STGY_PROC); db_printf("\n"); - db_utrace(td, tf, count, quitp); + db_utrace(td, tf, count); } return (user); } @@ -236,7 +236,6 @@ db_addr_t pc; int trap; int user; - int quit; if (count == -1) count = 1024; @@ -244,9 +243,7 @@ trap = 0; user = 0; npc = 0; - quit = 0; - db_setup_paging(db_simple_pager, &quit, db_lines_per_page); - while (count-- && !user && !quit) { + while (count-- && !user && !db_pager_quit) { pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, sizeof(fp->fr_pc), FALSE); if (trap) { @@ -272,7 +269,7 @@ tf = (struct trapframe *)(fp + 1); npc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); - user = db_print_trap(td, tf, count, &quit); + user = db_print_trap(td, tf, count); trap = 1; } else { db_printf("%s() at ", name);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607121334.k6CDYoqd037498>