printf() by kernel and servers now send messages to an array of processes,
OUTPUT_PROCS_ARRAY in <minix/config.h>, in that order, terminated by NONE. log no longer forwards messages to tty itself. This leads to less funny loops and more robust debug-message handling. Also the list of processes receiving messages can easily be changed around or disabled by editing the array (e.g. disable it by changing the array to { NONE }.).
This commit is contained in:
parent
d87bfc438b
commit
ea75918df1
@ -29,8 +29,8 @@ $(LIBDRIVER):
|
|||||||
cd $d/libdriver && $(MAKE)
|
cd $d/libdriver && $(MAKE)
|
||||||
|
|
||||||
# install with other drivers
|
# install with other drivers
|
||||||
install: /usr/sbin/$(DRIVER)
|
install: /sbin/$(DRIVER)
|
||||||
/usr/sbin/$(DRIVER): $(DRIVER)
|
/sbin/$(DRIVER): $(DRIVER)
|
||||||
install -o root -cs $? $@
|
install -o root -cs $? $@
|
||||||
|
|
||||||
# clean up local files
|
# clean up local files
|
||||||
|
@ -91,7 +91,6 @@ PUBLIC int do_diagnostics(message *m)
|
|||||||
* user. It also saves a copy in a local buffer so that messages can be
|
* user. It also saves a copy in a local buffer so that messages can be
|
||||||
* reviewed at a later time.
|
* reviewed at a later time.
|
||||||
*/
|
*/
|
||||||
int result;
|
|
||||||
int proc_nr;
|
int proc_nr;
|
||||||
vir_bytes src;
|
vir_bytes src;
|
||||||
int count;
|
int count;
|
||||||
@ -99,13 +98,9 @@ PUBLIC int do_diagnostics(message *m)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
static char diagbuf[10240];
|
static char diagbuf[10240];
|
||||||
|
|
||||||
/* Forward the message to the TTY driver. Inform the TTY driver about the
|
/* Change SELF to actual process number. */
|
||||||
* original sender, so that it knows where the buffer to be printed is.
|
|
||||||
* The message type, DIAGNOSTICS, remains the same.
|
|
||||||
*/
|
|
||||||
if ((proc_nr = m->DIAG_PROC_NR) == SELF)
|
if ((proc_nr = m->DIAG_PROC_NR) == SELF)
|
||||||
m->DIAG_PROC_NR = proc_nr = m->m_source;
|
m->DIAG_PROC_NR = proc_nr = m->m_source;
|
||||||
result = _sendrec(TTY_PROC_NR, m);
|
|
||||||
|
|
||||||
/* Now also make a copy for the private buffer at the LOG server, so
|
/* Now also make a copy for the private buffer at the LOG server, so
|
||||||
* that the messages can be reviewed at a later time.
|
* that the messages can be reviewed at a later time.
|
||||||
@ -121,5 +116,5 @@ PUBLIC int do_diagnostics(message *m)
|
|||||||
}
|
}
|
||||||
log_append(diagbuf, i);
|
log_append(diagbuf, i);
|
||||||
|
|
||||||
return result;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -85,11 +85,16 @@
|
|||||||
#define ENABLE_BINCOMPAT 0 /* for binaries using obsolete calls */
|
#define ENABLE_BINCOMPAT 0 /* for binaries using obsolete calls */
|
||||||
#define ENABLE_SRCCOMPAT 0 /* for sources using obsolete calls */
|
#define ENABLE_SRCCOMPAT 0 /* for sources using obsolete calls */
|
||||||
|
|
||||||
/* Which process should receive diagnostics from the kernel and system?
|
/* Which processes should receive diagnostics from the kernel and system?
|
||||||
* Directly sending it to TTY only displays the output. Sending it to the
|
* Directly sending it to TTY only displays the output. Sending it to the
|
||||||
* log driver will cause the diagnostics to be buffered and displayed.
|
* log driver will cause the diagnostics to be buffered and displayed.
|
||||||
|
* Messages are sent by src/lib/sysutil/kputc.c to these processes, in
|
||||||
|
* the order of this array, which must be terminated by NONE. This is used
|
||||||
|
* by drivers and servers that printf().
|
||||||
|
* The kernel does this for its own kprintf() in kernel/utility.c, also using
|
||||||
|
* this array, but a slightly different mechanism.
|
||||||
*/
|
*/
|
||||||
#define OUTPUT_PROC_NR LOG_PROC_NR /* TTY_PROC_NR or LOG_PROC_NR */
|
#define OUTPUT_PROCS_ARRAY { TTY_PROC_NR, LOG_PROC_NR, NONE }
|
||||||
|
|
||||||
/* NR_CONS, NR_RS_LINES, and NR_PTYS determine the number of terminals the
|
/* NR_CONS, NR_RS_LINES, and NR_PTYS determine the number of terminals the
|
||||||
* system can handle.
|
* system can handle.
|
||||||
|
@ -139,7 +139,10 @@ int c; /* character to append */
|
|||||||
kmess.km_size += 1;
|
kmess.km_size += 1;
|
||||||
kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
|
kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
|
||||||
} else {
|
} else {
|
||||||
send_sig(OUTPUT_PROC_NR, SIGKMESS);
|
int p, outprocs[] = OUTPUT_PROCS_ARRAY;
|
||||||
|
for(p = 0; outprocs[p] != NONE; p++) {
|
||||||
|
send_sig(outprocs[p], SIGKMESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,17 @@ int c;
|
|||||||
message m;
|
message m;
|
||||||
|
|
||||||
if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
|
if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
|
||||||
|
int procs[] = OUTPUT_PROCS_ARRAY;
|
||||||
|
int p;
|
||||||
|
|
||||||
/* Send the buffer to the OUTPUT_PROC_NR driver. */
|
for(p = 0; procs[p] != NONE; p++) {
|
||||||
m.DIAG_BUF_COUNT = buf_count;
|
/* Send the buffer to this output driver. */
|
||||||
m.DIAG_PRINT_BUF = print_buf;
|
m.DIAG_BUF_COUNT = buf_count;
|
||||||
m.DIAG_PROC_NR = SELF;
|
m.DIAG_PRINT_BUF = print_buf;
|
||||||
m.m_type = DIAGNOSTICS;
|
m.DIAG_PROC_NR = SELF;
|
||||||
(void) _sendrec(OUTPUT_PROC_NR, &m);
|
m.m_type = DIAGNOSTICS;
|
||||||
|
(void) _sendrec(procs[p], &m);
|
||||||
|
}
|
||||||
buf_count = 0;
|
buf_count = 0;
|
||||||
|
|
||||||
/* If the output fails, e.g., due to an ELOCKED, do not retry output
|
/* If the output fails, e.g., due to an ELOCKED, do not retry output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user