Conditionalize kern.tty_info_kstacks feature on STACKS option

Fix tinderbox (mips XLPN32) after r339471.

Reported by:	tinderbox
X-MFC-With:	r339471
Sponsored by:	Dell EMC Isilon
This commit is contained in:
cem 2018-10-22 17:42:57 +00:00
parent 816ca801ac
commit 7451598e04

View File

@ -236,10 +236,12 @@ sbuf_tty_drain(void *a, const char *d, int len)
return (-ENXIO); return (-ENXIO);
} }
#ifdef STACK
static bool tty_info_kstacks = false; static bool tty_info_kstacks = false;
SYSCTL_BOOL(_kern, OID_AUTO, tty_info_kstacks, CTLFLAG_RWTUN, SYSCTL_BOOL(_kern, OID_AUTO, tty_info_kstacks, CTLFLAG_RWTUN,
&tty_info_kstacks, 0, &tty_info_kstacks, 0,
"Enable printing kernel stack(9) traces on ^T (tty info)"); "Enable printing kernel stack(9) traces on ^T (tty info)");
#endif
/* /*
* Report on state of foreground process group. * Report on state of foreground process group.
@ -248,13 +250,16 @@ void
tty_info(struct tty *tp) tty_info(struct tty *tp)
{ {
struct timeval rtime, utime, stime; struct timeval rtime, utime, stime;
#ifdef STACK
struct stack stack; struct stack stack;
int sterr;
#endif
struct proc *p, *ppick; struct proc *p, *ppick;
struct thread *td, *tdpick; struct thread *td, *tdpick;
const char *stateprefix, *state; const char *stateprefix, *state;
struct sbuf sb; struct sbuf sb;
long rss; long rss;
int load, pctcpu, sterr; int load, pctcpu;
pid_t pid; pid_t pid;
char comm[MAXCOMLEN + 1]; char comm[MAXCOMLEN + 1];
struct rusage ru; struct rusage ru;
@ -329,6 +334,7 @@ tty_info(struct tty *tp)
else else
state = "unknown"; state = "unknown";
pctcpu = (sched_pctcpu(td) * 10000 + FSCALE / 2) >> FSHIFT; pctcpu = (sched_pctcpu(td) * 10000 + FSCALE / 2) >> FSHIFT;
#ifdef STACK
if (tty_info_kstacks) { if (tty_info_kstacks) {
stack_zero(&stack); stack_zero(&stack);
if (TD_IS_SWAPPED(td) || TD_IS_RUNNING(td)) if (TD_IS_SWAPPED(td) || TD_IS_RUNNING(td))
@ -338,6 +344,7 @@ tty_info(struct tty *tp)
sterr = 0; sterr = 0;
} }
} }
#endif
thread_unlock(td); thread_unlock(td);
if (p->p_state == PRS_NEW || p->p_state == PRS_ZOMBIE) if (p->p_state == PRS_NEW || p->p_state == PRS_ZOMBIE)
rss = 0; rss = 0;
@ -359,8 +366,10 @@ tty_info(struct tty *tp)
(long)stime.tv_sec, stime.tv_usec / 10000, (long)stime.tv_sec, stime.tv_usec / 10000,
pctcpu / 100, rss); pctcpu / 100, rss);
#ifdef STACK
if (tty_info_kstacks && sterr == 0) if (tty_info_kstacks && sterr == 0)
stack_sbuf_print_flags(&sb, &stack, M_NOWAIT); stack_sbuf_print_flags(&sb, &stack, M_NOWAIT);
#endif
out: out:
sbuf_finish(&sb); sbuf_finish(&sb);