Print this page
11693 Document mdb(1) ::ps flags
Reviewed by: John Levon <john.levon@joyent.com>


 340 
 341         mdb_printf("%c %6d %6d %6d %6d ",
 342             pstat2ch(pr.p_stat), pid.pid_id, pr.p_ppid, pgid.pid_id,
 343             sid.pid_id);
 344         if (prt_flags & PS_TASKS)
 345                 mdb_printf("%5d ", tk.tk_tkid);
 346         if (prt_flags & PS_PROJECTS)
 347                 mdb_printf("%5d ", pj.kpj_id);
 348         if (prt_flags & PS_ZONES)
 349                 mdb_printf("%5d ", zn.zone_id);
 350         mdb_printf("%6d 0x%08x %0?p %s\n",
 351             cred.cr_uid, pr.p_flag, addr,
 352             (prt_flags & PS_PSARGS) ? pr.p_user.u_psargs : pr.p_user.u_comm);
 353 
 354         if (prt_flags & ~PS_PSARGS)
 355                 (void) mdb_pwalk("thread", ps_threadprint, &prt_flags, addr);
 356 
 357         return (DCMD_OK);
 358 }
 359 









































 360 #define PG_NEWEST       0x0001
 361 #define PG_OLDEST       0x0002
 362 #define PG_PIPE_OUT     0x0004
 363 #define PG_EXACT_MATCH  0x0008
 364 
 365 typedef struct pgrep_data {
 366         uint_t pg_flags;
 367         uint_t pg_psflags;
 368         uintptr_t pg_xaddr;
 369         hrtime_t pg_xstart;
 370         const char *pg_pat;
 371 #ifndef _KMDB
 372         regex_t pg_reg;
 373 #endif
 374 } pgrep_data_t;
 375 
 376 typedef struct mdb_pgrep_proc {
 377         struct {
 378                 timestruc_t     u_start;
 379                 char            u_comm[MAXCOMLEN + 1];


4048         { "binding_hash_entry", ":", "print driver names hash table entry",
4049                 binding_hash_entry },
4050         { "callout", "?[-r|n] [-s|l] [-xhB] [-t | -ab nsec [-dkD]]"
4051             " [-C addr | -S seqid] [-f name|addr] [-p name| addr] [-T|L [-E]]"
4052             " [-FivVA]",
4053             "display callouts", callout, callout_help },
4054         { "calloutid", "[-d|v] xid", "print callout by extended id",
4055             calloutid, calloutid_help },
4056         { "class", NULL, "print process scheduler classes", class },
4057         { "cpuinfo", "?[-v]", "print CPUs and runnable threads", cpuinfo },
4058         { "did2thread", "? kt_did", "find kernel thread for this id",
4059                 did2thread },
4060         { "errorq", "?[-v]", "display kernel error queues", errorq },
4061         { "fd", ":[fd num]", "get a file pointer from an fd", fd },
4062         { "flipone", ":", "the vik_rev_level 2 special", flipone },
4063         { "lminfo", NULL, "print lock manager information", lminfo },
4064         { "ndi_event_hdl", "?", "print ndi_event_hdl", ndi_event_hdl },
4065         { "panicinfo", NULL, "print panic information", panicinfo },
4066         { "pid2proc", "?", "convert PID to proc_t address", pid2proc },
4067         { "project", NULL, "display kernel project(s)", project },
4068         { "ps", "[-fltzTP]", "list processes (and associated thr,lwp)", ps },

4069         { "pflags", NULL, "display various proc_t flags", pflags },
4070         { "pgrep", "[-x] [-n | -o] pattern",
4071                 "pattern match against all processes", pgrep },
4072         { "ptree", NULL, "print process tree", ptree },
4073         { "sysevent", "?[-sv]", "print sysevent pending or sent queue",
4074                 sysevent},
4075         { "sysevent_channel", "?", "print sysevent channel database",
4076                 sysevent_channel},
4077         { "sysevent_class_list", ":", "print sysevent class list",
4078                 sysevent_class_list},
4079         { "sysevent_subclass_list", ":",
4080                 "print sysevent subclass list", sysevent_subclass_list},
4081         { "system", NULL, "print contents of /etc/system file", sysfile },
4082         { "task", NULL, "display kernel task(s)", task },
4083         { "time", "[-dlx]", "display system time", time, time_help },
4084         { "vnode2path", ":[-F]", "vnode address to pathname", vnode2path },
4085         { "whereopen", ":", "given a vnode, dumps procs which have it open",
4086             whereopen },
4087 
4088         /* from bio.c */




 340 
 341         mdb_printf("%c %6d %6d %6d %6d ",
 342             pstat2ch(pr.p_stat), pid.pid_id, pr.p_ppid, pgid.pid_id,
 343             sid.pid_id);
 344         if (prt_flags & PS_TASKS)
 345                 mdb_printf("%5d ", tk.tk_tkid);
 346         if (prt_flags & PS_PROJECTS)
 347                 mdb_printf("%5d ", pj.kpj_id);
 348         if (prt_flags & PS_ZONES)
 349                 mdb_printf("%5d ", zn.zone_id);
 350         mdb_printf("%6d 0x%08x %0?p %s\n",
 351             cred.cr_uid, pr.p_flag, addr,
 352             (prt_flags & PS_PSARGS) ? pr.p_user.u_psargs : pr.p_user.u_comm);
 353 
 354         if (prt_flags & ~PS_PSARGS)
 355                 (void) mdb_pwalk("thread", ps_threadprint, &prt_flags, addr);
 356 
 357         return (DCMD_OK);
 358 }
 359 
 360 static void
 361 ps_help(void)
 362 {
 363         mdb_printf("Display processes.\n\n"
 364             "Options:\n"
 365             "    -f\tDisplay command arguments\n"
 366             "    -l\tDisplay LWPs\n"
 367             "    -T\tDisplay tasks\n"
 368             "    -P\tDisplay projects\n"
 369             "    -z\tDisplay zones\n"
 370             "    -t\tDisplay threads\n\n");
 371 
 372         mdb_printf("The resulting output is a table of the processes on the "
 373             "system.  The\n"
 374             "columns in the output consist of a combination of the "
 375             "following fields:\n\n");
 376         mdb_printf("S\tProcess state.  Possible states are:\n"
 377             "\tS\tSleeping (SSLEEP)\n"
 378             "\tR\tRunnable (SRUN)\n"
 379             "\tZ\tZombie (SZOMB)\n"
 380             "\tI\tIdle (SIDL)\n"
 381             "\tO\tOn Cpu (SONPROC)\n"
 382             "\tT\tStopped (SSTOP)\n"
 383             "\tW\tWaiting (SWAIT)\n");
 384 
 385         mdb_printf("PID\tProcess id.\n");
 386         mdb_printf("PPID\tParent process id.\n");
 387         mdb_printf("PGID\tProcess group id.\n");
 388         mdb_printf("SID\tProcess id of the session leader.\n");
 389         mdb_printf("TASK\tThe task id of the process.\n");
 390         mdb_printf("PROJ\tThe project id of the process.\n");
 391         mdb_printf("ZONE\tThe zone id of the process.\n");
 392         mdb_printf("UID\tThe user id of the process.\n");
 393         mdb_printf("FLAGS\tThe process flags (see ::pflags).\n");
 394         mdb_printf("ADDR\tThe kernel address of the proc_t structure of the "
 395             "process\n");
 396         mdb_printf("NAME\tThe name (p_user.u_comm field) of the process.  If "
 397             "the -f flag\n"
 398             "\tis specified, the arguments of the process are displayed.\n");
 399 }
 400 
 401 #define PG_NEWEST       0x0001
 402 #define PG_OLDEST       0x0002
 403 #define PG_PIPE_OUT     0x0004
 404 #define PG_EXACT_MATCH  0x0008
 405 
 406 typedef struct pgrep_data {
 407         uint_t pg_flags;
 408         uint_t pg_psflags;
 409         uintptr_t pg_xaddr;
 410         hrtime_t pg_xstart;
 411         const char *pg_pat;
 412 #ifndef _KMDB
 413         regex_t pg_reg;
 414 #endif
 415 } pgrep_data_t;
 416 
 417 typedef struct mdb_pgrep_proc {
 418         struct {
 419                 timestruc_t     u_start;
 420                 char            u_comm[MAXCOMLEN + 1];


4089         { "binding_hash_entry", ":", "print driver names hash table entry",
4090                 binding_hash_entry },
4091         { "callout", "?[-r|n] [-s|l] [-xhB] [-t | -ab nsec [-dkD]]"
4092             " [-C addr | -S seqid] [-f name|addr] [-p name| addr] [-T|L [-E]]"
4093             " [-FivVA]",
4094             "display callouts", callout, callout_help },
4095         { "calloutid", "[-d|v] xid", "print callout by extended id",
4096             calloutid, calloutid_help },
4097         { "class", NULL, "print process scheduler classes", class },
4098         { "cpuinfo", "?[-v]", "print CPUs and runnable threads", cpuinfo },
4099         { "did2thread", "? kt_did", "find kernel thread for this id",
4100                 did2thread },
4101         { "errorq", "?[-v]", "display kernel error queues", errorq },
4102         { "fd", ":[fd num]", "get a file pointer from an fd", fd },
4103         { "flipone", ":", "the vik_rev_level 2 special", flipone },
4104         { "lminfo", NULL, "print lock manager information", lminfo },
4105         { "ndi_event_hdl", "?", "print ndi_event_hdl", ndi_event_hdl },
4106         { "panicinfo", NULL, "print panic information", panicinfo },
4107         { "pid2proc", "?", "convert PID to proc_t address", pid2proc },
4108         { "project", NULL, "display kernel project(s)", project },
4109         { "ps", "[-fltzTP]", "list processes (and associated thr,lwp)", ps,
4110             ps_help },
4111         { "pflags", NULL, "display various proc_t flags", pflags },
4112         { "pgrep", "[-x] [-n | -o] pattern",
4113                 "pattern match against all processes", pgrep },
4114         { "ptree", NULL, "print process tree", ptree },
4115         { "sysevent", "?[-sv]", "print sysevent pending or sent queue",
4116                 sysevent},
4117         { "sysevent_channel", "?", "print sysevent channel database",
4118                 sysevent_channel},
4119         { "sysevent_class_list", ":", "print sysevent class list",
4120                 sysevent_class_list},
4121         { "sysevent_subclass_list", ":",
4122                 "print sysevent subclass list", sysevent_subclass_list},
4123         { "system", NULL, "print contents of /etc/system file", sysfile },
4124         { "task", NULL, "display kernel task(s)", task },
4125         { "time", "[-dlx]", "display system time", time, time_help },
4126         { "vnode2path", ":[-F]", "vnode address to pathname", vnode2path },
4127         { "whereopen", ":", "given a vnode, dumps procs which have it open",
4128             whereopen },
4129 
4130         /* from bio.c */