Changeset 26684
- Timestamp:
- 07/30/08 06:03:22 (4 months ago)
- Location:
- haiku/trunk
- Files:
-
- 3 modified
-
headers/private/kernel/util/ring_buffer.h (modified) (1 diff)
-
src/system/kernel/debug/debug.cpp (modified) (5 diffs)
-
src/system/kernel/util/ring_buffer.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/headers/private/kernel/util/ring_buffer.h
r12357 r26684 10 10 11 11 12 struct ring_buffer; 12 struct ring_buffer { 13 int32 first; 14 int32 in; 15 int32 size; 16 uint8 buffer[0]; 17 }; 18 13 19 14 20 #ifdef __cplusplus -
haiku/trunk/src/system/kernel/debug/debug.cpp
r26581 r26684 1 1 /* 2 * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de 2 * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. 3 3 * Distributed under the terms of the MIT License. 4 4 * … … 651 651 sDebuggerOnCPU = smp_get_current_cpu(); 652 652 653 // set a few temporary debug variables 653 kprintf("Welcome to Kernel Debugging Land...\n"); 654 654 655 if (struct thread* thread = thread_get_current_thread()) { 656 // set a few temporary debug variables 655 657 set_debug_variable("_thread", (uint64)(addr_t)thread); 656 658 set_debug_variable("_threadID", thread->id); … … 658 660 set_debug_variable("_teamID", thread->team->id); 659 661 set_debug_variable("_cpu", sDebuggerOnCPU); 660 } 661 662 kprintf("Welcome to Kernel Debugging Land...\n"); 663 kprintf("Running on CPU %ld\n", sDebuggerOnCPU); 662 663 kprintf("Thread %ld \"%s\" running on CPU %ld\n", thread->id, 664 thread->name, sDebuggerOnCPU); 665 } else 666 kprintf("Running on CPU %ld\n", sDebuggerOnCPU); 664 667 665 668 int32 continuableLine = -1; … … 719 722 720 723 724 static int 725 cmd_dump_syslog(int argc, char **argv) 726 { 727 if (!sSyslogOutputEnabled) { 728 kprintf("Syslog is not enabled.\n"); 729 return 0; 730 } 731 732 bool currentOnly = false; 733 if (argc > 1) { 734 if (!strcmp(argv[1], "-n")) 735 currentOnly = true; 736 else { 737 print_debugger_command_usage(argv[0]); 738 return 0; 739 } 740 } 741 742 uint32 start = sSyslogBuffer->first; 743 size_t end = start + sSyslogBuffer->in; 744 if (!currentOnly) { 745 // Start the buffer after the current end (we don't really know if 746 // this part has been written to already). 747 start = (start + sSyslogBuffer->in) % sSyslogBuffer->size; 748 end = start + sSyslogBuffer->size; 749 } else if (!ring_buffer_readable(sSyslogBuffer)) { 750 kprintf("Syslog is empty.\n"); 751 return 0; 752 } 753 754 // break it down to lines to make it grep'able 755 756 bool newLine = false; 757 char line[256]; 758 size_t linePos = 0; 759 for (int32 i = start; i < end; i++) { 760 char c = sSyslogBuffer->buffer[i % sSyslogBuffer->size]; 761 if (c == '\0' || (uint8)c == 0xcc) 762 continue; 763 764 line[linePos++] = c; 765 newLine = false; 766 767 if (c == '\n' || linePos == sizeof(line) - 1) { 768 newLine = c == '\n'; 769 line[linePos] = '\0'; 770 linePos = 0; 771 kprintf(line); 772 } 773 } 774 if (!newLine) 775 kprintf("\n"); 776 777 return 0; 778 } 779 780 721 781 static status_t 722 782 syslog_sender(void *data) … … 880 940 get_haiku_revision()); 881 941 syslog_write(revisionBuffer, length); 942 943 add_debugger_command_etc("syslog", &cmd_dump_syslog, 944 "Dumps the syslog buffer.\n", 945 "[-n]\nDumps the whole syslog buffer, or, if -n is specified, only " 946 "the part that hasn't been send yet.\n", 0); 882 947 return B_OK; 883 948 -
haiku/trunk/src/system/kernel/util/ring_buffer.cpp
r18391 r26684 1 1 /* 2 * Copyright 2005-200 6, Axel Dörfler, axeld@pinc-software.de. All rights reserved.2 * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. 3 3 * Distributed under the terms of the MIT License. 4 4 */ … … 19 19 #endif 20 20 21 /* *This is a light-weight ring_buffer implementation.21 /*! This is a light-weight ring_buffer implementation. 22 22 * It does not provide any locking - you are supposed to ensure thread-safety 23 23 * with the restrictions you choose. Unless you are passing in unsafe buffers, … … 26 26 * They also don't use malloc() or any kind of locking after initialization. 27 27 */ 28 29 struct ring_buffer {30 int32 first;31 int32 in;32 int32 size;33 uint8 buffer[0];34 };35 28 36 29
