Page MenuHomeFreeBSD

D17621.id49343.diff
No OneTemporary

D17621.id49343.diff

Index: head/sys/kern/tty_info.c
===================================================================
--- head/sys/kern/tty_info.c
+++ head/sys/kern/tty_info.c
@@ -49,11 +49,14 @@
#include <sys/cons.h>
#include <sys/kdb.h>
#include <sys/lock.h>
+#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
+#include <sys/stack.h>
+#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/tty.h>
@@ -233,6 +236,11 @@
return (-ENXIO);
}
+static bool tty_info_kstacks = false;
+SYSCTL_BOOL(_kern, OID_AUTO, tty_info_kstacks, CTLFLAG_RWTUN,
+ &tty_info_kstacks, 0,
+ "Enable printing kernel stack(9) traces on ^T (tty info)");
+
/*
* Report on state of foreground process group.
*/
@@ -240,12 +248,13 @@
tty_info(struct tty *tp)
{
struct timeval rtime, utime, stime;
+ struct stack stack;
struct proc *p, *ppick;
struct thread *td, *tdpick;
const char *stateprefix, *state;
struct sbuf sb;
long rss;
- int load, pctcpu;
+ int load, pctcpu, sterr;
pid_t pid;
char comm[MAXCOMLEN + 1];
struct rusage ru;
@@ -320,6 +329,15 @@
else
state = "unknown";
pctcpu = (sched_pctcpu(td) * 10000 + FSCALE / 2) >> FSHIFT;
+ if (tty_info_kstacks) {
+ stack_zero(&stack);
+ if (TD_IS_SWAPPED(td) || TD_IS_RUNNING(td))
+ sterr = stack_save_td_running(&stack, td);
+ else {
+ stack_save_td(&stack, td);
+ sterr = 0;
+ }
+ }
thread_unlock(td);
if (p->p_state == PRS_NEW || p->p_state == PRS_ZOMBIE)
rss = 0;
@@ -340,6 +358,9 @@
(long)utime.tv_sec, utime.tv_usec / 10000,
(long)stime.tv_sec, stime.tv_usec / 10000,
pctcpu / 100, rss);
+
+ if (tty_info_kstacks && sterr == 0)
+ stack_sbuf_print_flags(&sb, &stack, M_NOWAIT);
out:
sbuf_finish(&sb);

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 21, 6:11 AM (5 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28912148
Default Alt Text
D17621.id49343.diff (1 KB)

Event Timeline