Corrected the repeat checks (did not compare the right buffers) and added a length argument to debug_puts() to safe the strlen in the syslog case. Also removed some leftover.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16991 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,7 +32,7 @@ extern status_t debug_init(struct kernel_args *args);
|
|||||||
extern status_t debug_init_post_vm(struct kernel_args *args);
|
extern status_t debug_init_post_vm(struct kernel_args *args);
|
||||||
extern status_t debug_init_post_modules(struct kernel_args *args);
|
extern status_t debug_init_post_modules(struct kernel_args *args);
|
||||||
extern void debug_early_boot_message(const char *string);
|
extern void debug_early_boot_message(const char *string);
|
||||||
extern void debug_puts(const char *s);
|
extern void debug_puts(const char *s, int32 length);
|
||||||
extern bool debug_debugger_running(void);
|
extern bool debug_debugger_running(void);
|
||||||
extern void debug_stop_screen_debug_output(void);
|
extern void debug_stop_screen_debug_output(void);
|
||||||
|
|
||||||
|
|||||||
@@ -88,14 +88,14 @@ dprintf_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
|
|||||||
memcpy(localBuffer, str, chunkSize);
|
memcpy(localBuffer, str, chunkSize);
|
||||||
localBuffer[chunkSize] = '\0';
|
localBuffer[chunkSize] = '\0';
|
||||||
|
|
||||||
debug_puts(localBuffer);
|
debug_puts(localBuffer, chunkSize);
|
||||||
|
|
||||||
str += chunkSize;
|
str += chunkSize;
|
||||||
bytesLeft -= chunkSize;
|
bytesLeft -= chunkSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// null-terminated chunk -- just write it
|
// null-terminated chunk -- just write it
|
||||||
debug_puts(str);
|
debug_puts(str, chunkSize);
|
||||||
|
|
||||||
str += chunkSize + 1;
|
str += chunkSize + 1;
|
||||||
bytesLeft -= chunkSize + 1;
|
bytesLeft -= chunkSize + 1;
|
||||||
|
|||||||
@@ -579,32 +579,30 @@ debug_debugger_running(void)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
debug_puts(const char *string)
|
debug_puts(const char *string, int32 length)
|
||||||
{
|
{
|
||||||
cpu_status state;
|
cpu_status state = disable_interrupts();
|
||||||
int64 newHash;
|
|
||||||
|
|
||||||
// we only need the length for syslog
|
|
||||||
size_t length = 0;
|
|
||||||
if (sSyslogOutputEnabled)
|
|
||||||
length = strlen(string);
|
|
||||||
|
|
||||||
state = disable_interrupts();
|
|
||||||
acquire_spinlock(&sSpinlock);
|
acquire_spinlock(&sSpinlock);
|
||||||
|
|
||||||
if (strncmp(sOutputBuffer, sLastOutputBuffer, OUTPUT_BUFFER_SIZE) == 0) {
|
if (length >= OUTPUT_BUFFER_SIZE)
|
||||||
|
length = OUTPUT_BUFFER_SIZE - 1;
|
||||||
|
|
||||||
|
if (strncmp(string, sLastOutputBuffer, length) == 0
|
||||||
|
&& length > 0 && string[length - 1] == '\n') {
|
||||||
sMessageRepeatCount++;
|
sMessageRepeatCount++;
|
||||||
sMessageRepeatTime = system_time();
|
sMessageRepeatTime = system_time();
|
||||||
} else {
|
} else {
|
||||||
flush_pending_repeats();
|
flush_pending_repeats();
|
||||||
kputs(string);
|
kputs(string);
|
||||||
memcpy(sLastOutputBuffer, sOutputBuffer, OUTPUT_BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// kputs() doesn't output to syslog (as it's only used
|
// kputs() doesn't output to syslog (as it's only used
|
||||||
// from the kernel debugger elsewhere)
|
// from the kernel debugger elsewhere)
|
||||||
if (sSyslogOutputEnabled)
|
if (sSyslogOutputEnabled)
|
||||||
syslog_write(sOutputBuffer, length);
|
syslog_write(string, length);
|
||||||
|
|
||||||
|
memcpy(sLastOutputBuffer, string, length);
|
||||||
|
sLastOutputBuffer[length] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
release_spinlock(&sSpinlock);
|
release_spinlock(&sSpinlock);
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
@@ -866,7 +864,6 @@ dprintf(const char *format, ...)
|
|||||||
{
|
{
|
||||||
cpu_status state;
|
cpu_status state;
|
||||||
va_list args;
|
va_list args;
|
||||||
int64 newHash;
|
|
||||||
int32 length;
|
int32 length;
|
||||||
|
|
||||||
if (!sSerialDebugEnabled && !sSyslogOutputEnabled && !sBlueScreenEnabled)
|
if (!sSerialDebugEnabled && !sSyslogOutputEnabled && !sBlueScreenEnabled)
|
||||||
@@ -883,7 +880,11 @@ dprintf(const char *format, ...)
|
|||||||
length = vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
length = vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (strncmp(sOutputBuffer, sLastOutputBuffer, length) == 0) {
|
if (length >= OUTPUT_BUFFER_SIZE)
|
||||||
|
length = OUTPUT_BUFFER_SIZE - 1;
|
||||||
|
|
||||||
|
if (strncmp(sOutputBuffer, sLastOutputBuffer, length) == 0
|
||||||
|
&& length > 0 && sOutputBuffer[length - 1] == '\n') {
|
||||||
sMessageRepeatCount++;
|
sMessageRepeatCount++;
|
||||||
sMessageRepeatTime = system_time();
|
sMessageRepeatTime = system_time();
|
||||||
} else {
|
} else {
|
||||||
@@ -897,6 +898,7 @@ dprintf(const char *format, ...)
|
|||||||
blue_screen_puts(sOutputBuffer);
|
blue_screen_puts(sOutputBuffer);
|
||||||
|
|
||||||
memcpy(sLastOutputBuffer, sOutputBuffer, length);
|
memcpy(sLastOutputBuffer, sOutputBuffer, length);
|
||||||
|
sLastOutputBuffer[length] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_spinlock(&sSpinlock);
|
release_spinlock(&sSpinlock);
|
||||||
@@ -919,6 +921,7 @@ kprintf(const char *format, ...)
|
|||||||
vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
flush_pending_repeats();
|
||||||
kputs(sOutputBuffer);
|
kputs(sOutputBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -941,7 +944,7 @@ _user_debug_output(const char *userString)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
length = user_strlcpy(string, userString, sizeof(string));
|
length = user_strlcpy(string, userString, sizeof(string));
|
||||||
debug_puts(string);
|
debug_puts(string, length);
|
||||||
userString += sizeof(string) - 1;
|
userString += sizeof(string) - 1;
|
||||||
} while (length >= (ssize_t)sizeof(string));
|
} while (length >= (ssize_t)sizeof(string));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user