History log of /haiku/headers/private/kernel/debug.h
Revision Date Author Comments
# 0ac46a4a 31-Aug-2021 Augustin Cavalier <waddlesplash@gmail.com>

kernel/debug: Adjust range marker macros.

Previously these were just using the raw function name, which led
to markers like "Slab_begin". Now we prefix RANGE_MARKER_ so there
is absolutely no chance of confusion, and the symbols are clearly
visible in dumps.

Also add a note that the kernel must be built with -fno-toplevel-reorder
for these to work. (It seems when this was implemented, GCC had not yet
implemented top-level reordering.)

They are only used for debugging with the tracing system in a handful
of places, and -ftoplevel-reorder is enabled with optimizations for
a reason, so it makes more sense just to note this and not to enable
that option by default (i.e. in the off chance someone will want to
use these in non-debug builds, like I did.)


# 47a21c5c 30-Aug-2019 Augustin Cavalier <waddlesplash@gmail.com>

s/Haiku License/MIT License/g.

They are the same thing.


# 47b079af 21-Aug-2018 Augustin Cavalier <waddlesplash@gmail.com>

Debug.h: Implement a real STATIC_ASSERT on non-GCC2.


# 4bf862e3 21-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

syslog_daemon: Converted to BServer.

* Instead of letting the kernel search for the syslog port, the
daemon now registers itself with the kernel (which even solves
a TODO).
* A port is created for the actual log messages from the launch_daemon,
and used on start.
* However, the SyslogTest does not yet work, due to the BMessage <->
KMessage communication problems.


# 97ac7257 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
Add helper macros for placing markers in the source, so we can get the
address ranges of code we're interested in.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43071 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f498c079 10-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added STATIC_ASSERT() macro (from <Debug.h>, which cannot be included in the
kernel).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37087 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c8fcd77 05-May-2010 Axel Dörfler <axeld@pinc-software.de>

* Moved the addition of the basic debugger commands directly after the VM init.
* Separated the other stuff previously done in debug_init_post_vm() to the new
debug_init_post_settings().
* Removed superfluous status_t return codes - they are ignored, anyway, and if
there really is a show stopper in the init process, panicking would be the
thing one should do.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3676b54 13-Apr-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added vm_debug_copy_page_memory() which copies memory from a potentially not
mapped page.
* debug_{mem,strl}cpy():
- Added "team" parameter for specifying the address space the address are
to be interpreted in.
- When the standard memcpy() (with fault handler) fails, fall back to
vm_debug_copy_page_memory().
* Added debug_is_debugged_team(): Predicate returning true, if the supplied
team_id refers to the same team debug_get_debugged_thread() belongs to.
* Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread().
Made use of it in several debugger functions.
* print_demangled_call() (x86): Fixed unsafe memory access.

Allows KDL stack traces to work correctly again, even if the page daemon has
already unmapped the concerned pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cfefeee3 18-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed arch_debug_save_registers() to take an arch-specific structure
arch_debug_registers instead.
* Call arch_debug_save_registers() on all CPUs when entering the kernel
debugger.
* Added debug_get_debug_registers() to return a specified CPU's saved
registers.
* x86:
- Replaced the previous arch_debug_save_registers() implementation. Disabled
getting the registers via the gdb interface for the time being.
- Fixed the "sc", "call", and "calling" commands to also work for threads
running on another CPU.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8b522fcf 20-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed ASSERT_[ALWAYS_]PRINT() to add the additional output to the panic()
message instead of printing it before calling panic().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be51dd0f 30-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added debug_strlcpy() for use in the kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33380 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea2abd11 02-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of
ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of
two anyway and this implementation works for other numbers as well.
* The thread::fault_handler use in C[++] code was broken with gcc 4. At least
when other functions were invoked. Trying to trick the compiler wasn't a
particularly good idea anyway, since the next compiler version could break
the trick again. So the general policy is to use the fault handlers only in
assembly code where we have full control. Changed that for x86 (save for the
vm86 mode, which has a similar mechanism), but not for the other
architectures.
* Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer
fields in the cpu_ent structure, which must be used instead of
thread::fault_handler in the kernel debugger. Consequently user_memcpy() must
not be used in the kernel debugger either. Introduced a debug_memcpy()
instead.
* Introduced debug_call_with_fault_handler() function which calls a function
in a setjmp() and fault handler context. The architecture specific backend
arch_debug_call_with_fault_handler() has only been implemented for x86 yet.
* Introduced debug_is_kernel_memory_accessible() for use in the kernel
debugger. It determines whether a range of memory can be accessed in the
way specified. The architecture specific back end
arch_vm_translation_map_is_kernel_page_accessible() has only been implemented
for x86 yet.
* Added arch_debug_unset_current_thread() (only implemented for x86) to unset
the current thread pointer in the kernel debugger. When entering the kernel
debugger we do some basic sanity checks of the currently set thread structure
and unset it, if they fail. This allows certain commands (most importantly
the stack trace command) to avoid accessing the thread structure.
* x86: When handling a double fault, we do now install a special handler for
page faults. This allows us to gracefully catch faulting commands, even if
e.g. the thread structure is toast.

We are now in much better shape to deal with double faults. Hopefully avoiding
the triple faults that some people have been experiencing on their hardware
and ideally even allowing to use the kernel debugger normally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32073 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 671a2442 31-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

More work towards making our double fault handler less triple fault prone:
* SMP:
- Added smp_send_broadcast_ici_interrupts_disabled(), which is basically
equivalent to smp_send_broadcast_ici(), but is only called with interrupts
disabled and gets the CPU index, so it doesn't have to use
smp_get_current_cpu() (which dereferences the current thread).
- Added cpu index parameter to smp_intercpu_int_handler().
* x86:
- arch_int.c -> arch_int.cpp
- Set up an IDT per CPU. We were using a single IDT for all CPUs, but that
can't work, since we need different tasks for the double fault interrupt
vector.
- Set the per CPU double fault task gates correctly.
- Renamed set_intr_gate() to set_interrupt_gate and set_system_gate() to
set_trap_gate() and documented them a bit.
- Renamed double_fault_exception() x86_double_fault_exception() and fixed
it not to use smp_get_current_cpu(). Instead we have the new
x86_double_fault_get_cpu() that deducts the CPU index from the used stack.
- Fixed the double_fault interrupt handler: It no longer calls int_bottom to
avoid accessing the current thread.
* debug.cpp:
- Introduced explicit debug_double_fault() to enter the kernel debugger from
a double fault handler.
- Avoid using smp_get_current_cpu().
- Don't use kprintf() before sDebuggerOnCPU is set. Otherwise
acquire_spinlock() is invoked by arch_debug_serial_puts().

Things look a bit better when the current thread pointer is broken -- we run
into kernel_debugger_loop() and successfully print the "Welcome to KDL"
message -- but we still dereference the thread pointer afterwards, so that we
don't get a usable kernel debugger yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32050 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 213d2d8f 29-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added syscall _kern_kernel_debugger() to enter the kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c755ecfe 20-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Added an emergency key mechanism to the kernel, inspired by Jan Klötzke's
patch from about a year ago (I couldn't use any code of his yet, though,
but there are a few things left). The emergency keys are triggered by
pressing Alt-SysReq + key.
* By default, only Alt-SysReq+'d' is used as a means to deliberately enter
the kernel debugger. F12 belongs to userland again, now :-)
* Debugger add-ons now have another optional method to implement their own
emergency keys - 'd' for the debugger cannot be overridden, though.
* The mechanism can be turned off via a new kernel setting, so it's not that
easy anymore to "crash" Haiku if you don't want to.
* Right now, the PS/2 driver, and the pre-input_server in-kernel debugger
keyboard mini-driver support this, USB not yet.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b9d5a2e 10-Mar-2009 Michael Lotz <mmlr@mlotz.ch>

* Add has_debugger_command() so whether or not a debugger command is available
can be checked.
* Make the usb_keyboard module check the presence of the needed debugger
commands to avoid the error messages in case of them being unavailable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29472 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eba0636 22-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Added simplified possibility to schedule UHCI transfers from within KDL.
* Added debugger commands to resolve usb_ids to pipes.
* Adjusted the physical memory allocator to be usable in a slimmed down mode
when running inside the kernel debugger.
* Implemented USB keyboard support for KDL through a kernel debugger add-on.
* Added kgetc() and made use of it where previously individual methods were used
to ensure that reading characters always goes through the kernel debugger
add-ons and the other methods.

This has some preconditions to meet though:
1) The keyboard must be in the boot protocol (currently the case but needs to
be revisited once we have a full usb_hid).
2) The keyboard must be attached to a UHCI root port (i.e. not use EHCI or OHCI,
also not through hubs unless those are USB 1.1).
3) the usb_hid driver has to be opened for this to work. This means that for the
time between initializing USB and when usb_hid is opened by the input_server
there is no keyboard support.

Also note that this has no way of detecting hot-plug, meaning that you can't
re-attach your USB keyboard from the hub to the root port once in KDL.

On the bright side of things, since this is a non-destructive mechanism it is
possible to enter and leave KDL without loosing the USB state.

Tested OK in QEMU, not tested on real hardware yet, will see in a few minutes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1894a0a9 20-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Consistently use KDEBUG. It is always defined and therefore must be
checked with "#if".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ab39de9 17-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed unused SMP_MSG_RESCHEDULE ICI message.
* Introduced flag "invoke_scheduler" in the per CPU structure. It is
evaluated in hardware_interrupt() (x86 only ATM).
* Introduced SMP_MSG_RESCHEDULE_IF_IDLE message, which enters the
scheduler when the CPU currently runs an idle thread.
* Don't do dprintf() "CPU x halted!" when handling a SMP_MSG_CPU_HALT
ICI message. It uses nested spinlocks and could thus potentially
deadlock itself (acquire_spinlock() processes ICI messages, so it
could already hold one of the locks). This is a pretty likely scenario
on machines with more than two CPUs, but is also possible when the
panic()ing thread holds the threads spinlock. Probably fixes #2572.
* Reworked the way the kernel debugger is entered and added a "cpu"
command that allows switching the CPU once in KDL. It is thus possible
to get a stack trace of the thread not on the panic()ing CPU.
* When a thread is added to the run queue, we do now check, if another
CPU is idle and ask it to reschedule, if it is. Before this change, the
CPU was continuing to idle until the quantum of the idle thread
expired. Speeds up the libbe.so build about 8% on my machine (haven't
tested the full Haiku image build yet).
* When spinlock debugging is enabled (DEBUG_SPINLOCKS) we also record
the spinlock acquirer on non-smp machines. Added "spinlock" debugger
command to get the info.
* Added debugger commands "ici" and "ici_message", printing info on
pending ICI message respectively on a given one.
* Process not only a single ICI message in acquire_spinlock() and other
places, but all pending ones.
* Also process ICI messages when waiting for a free one -- avoids a
potential deadlock.
* Mask out non-existing CPUs in send_multicast_ici(). panic() instead of
just returning when there's no target CPU left.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 945a6a41 15-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

bonefish + mmlr:
* Add possibility to restart a complete pipe through B_KDEBUG_RESTART_PIPE.
* Implement tail in the kernel debugger making use of the former.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ddecb4a7 12-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the way the demangle functionality works: instead of having a kernel
debugger add-on set a demangle hook, all modules under debugger/demangle/ are
now considered demangle modules.
* Added another function to the demangle module interface that gives you access
to the arguments.
* Implemented a demangling module for GCC2.
* The older demangling module is now called "gcc3+", but doesn't support
getting the arguments yet.
* The "call" KDL command is now using demangling to automatically show you
the arguments of a call from a stack crawl.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28018 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8bdc244 01-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Created a central place for putting kernel debug enabling macros.
Currently it only contains KDEBUG and the block cache debugging macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 290e3dd2 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduced the notion of a currently debugged thread in the kernel
debugger and added respective getter/setter methods
debug_{get,set}_debugged_thread(). By default the currently debugged
thread is the thread that dropped into the kernel debugger, but commands
like "in_context" can change it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27164 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0deddbe3 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function parse_next_debug_command_argument(), which parses the
first command line argument of a given command line string.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27155 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ec2301 12-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

When in the kernel debugger we do now record the relevant information
(fault address, pc, read/write) when a page fault occurs, and print them
in case this caused the termination of a debugger command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8881176f 23-Jul-2008 François Revol <revol@free.fr>

A module that hooks into the debugger to provide it with a demangle() so at least when using C++ in the kernel stack crawls are meaningful.
It does its job by using part of libsupc++, with fake malloc and friends to make sure it won't double fault.
Works here, but cp-demangle must be extracted by hand from the lib, can't get the rule to work as I want, Ingo ?
Maybe using it directly without malloc hack would be ok with 16KB buffer, but I'm not sure of that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26581 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eb0dca1d 17-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Add a KDEBUG_ONLY macro for easier handling of code only needed in case of KDEBUG.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26483 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73aa393d 31-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced pipes in the kernel debugger. The syntax is similar to
pipes in the shell, though the semantics is a little different: The
second command is invoked whenever the first command has written a
complete line. The line is passed as last argument to the second
command. The new command flag B_KDEBUG_PIPE_FINAL_RERUN causes the
second command to be invoked again (with NULL argument) after the
first command is done.
* Added kprintf_unfiltered() and kputs_unfiltered() which bypass the
pipe mechanism and directly print to the bluescreen/serial output.
* Moved most commands from debug.cpp to the new
debug_builtin_commands.cpp.
* B_KDEBUG_DONT_PARSE_ARGUMENTS commands don't get an argument anymore,
if it would consist of white space only.
* Added new debugger command return value B_KDEBUG_ERROR, which
indicates that executing the command failed. This return code will
abort a complete pipe.
* Since debugger commands can nest (i.e. one command can invoke another
one) the setjmp()/longjmp() mechanism to restore the stack after a
page fault in a command needs more than one jump buffer.
* Added abort_debugger_command(), which longjmp()s out of the currently
executed command. This will also abort the current pipe.
* When pagination is enabled pressing "a" will abort the running command
(as opposed to "q" which only disables the blue screen output, but
lets the command continue).
* Added debugger commands:
- "grep" which can be used to filter output by pattern. Removed the
"filter" command and the underlying mechanism that did that before.
- "head" which prints only the first lines of output of another
command.
- "wc" counts lines, words, and characters of another command's
output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25744 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a886f802 20-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added debug_screen_output_enabled() function.
* The boot splash code now checks wether debug screen output is enabled or not
using the above function.
* The boot splash code no longer maps it's own copy of the frame buffer, instead,
it will use the boot item feature as the VESA driver does. Also removed the
lock, as that's not needed at all.
* Renamed splash.cpp to boot_splash.cpp, and boot/splash.h to boot_splash.h
(it's not part of the boot loader, but the kernel).
* Removed dead code from boot_splash.cpp, added license. Replaced license
header in boot_splash.h to a style guide conforming one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24489 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f393752 21-Feb-2008 François Revol <revol@free.fr>

Add debugger module hooks to implement alternative io (I need laplink debugging...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24052 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cec75dc 30-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Debugger modules now have two methods: enter_debugger() and exit_debugger().
* The kernel now opens up to 8 debugger modules (and puts them into an array;
maybe we'll want to switch to a doubly linked list when there is the need).
* Implemented an example debugger module that prints a stack trace of the
current thread when the kernel debugger is entered (not included in the
image).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 325b88a6 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced debugger command flag B_KDEBUG_DONT_PARSE_ARGUMENTS.
For commands with this flag set, the parser won't parse the
arguments provided (it will only check for matching parentheses and
brackets), but will pass the unparsed argument list string to the
command instead.
* Set the new flag for the "expr" command, so one doesn't have to quote
the expression to evaluate anymore (or put it in parentheses).
* Fixed tokenizing of quoted and unquoted strings in expression mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23697 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 90242589 20-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made kputs() available in the kernel and used it for printing debugger
command usage texts, which can be too long for kprintf().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a90d12e 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added add_debugger_command_etc() which is similar to
add_debugger_command(), but additionally takes parameters "usage"
and "flags".
* Added add_debugger_command_alias() which creates another name for an
existing command.
* Added print_debugger_command_usage() to print a command's usage.
* invoke_debugger_command() intercepts invocations with "--help" and
prints the command's usage text, if it is known. If unknown, the
command will be called normally.
* Made use of the new functions in debug.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23573 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 06f78e9f 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way temporary variables work. They won't be unset before
a command is executed anymore. Instead the least recently used
temporary variable is overwritten, if there's no free slot for a new
temporary variable.
* Removed the special handling for the command result variable ("_"). It
just works like any other temporary variable, now.
* Individual temporary variables can be removed (e.g. using the "unset"
command).
* Added unset_all_debug_variables() and "unset_all" command to unset
all persistent and temporary variables.
* Removed remove_all_temporary_debug_variables and renamed
remove_debug_variable() to unset_debug_variable().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b4fa166 15-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented parse_expression(). The back-end is an expression parser
that is a little more powerful than BeOS'. It features:
- Persistent and temporary uint64 variables. The former kind is set
only by the user. The latter (those prefixed "_") can be set
automatically by commands, thus e.g. making it easier to access
members of a dumped structure. They are unset when the next command
is invoked. The special temporary variable "_" is defined as a
command's return value.
- Expressions can contain nested command invocations using brackets
("[ ... ]").
- Command lines are parsed by the expression parser, too. They can
contain command invocations (in brackets) and expressions (in
parentheses).
* Added debugger commands:
- expr: Evaluates the given expression and prints the result.
- unset: Undefines a variable.
- vars: Prints the values of all defined variables.
* Moved debugger command code into its own source file.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 76ab7bdc 03-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function dprintf_no_syslog(). It is basically equivalent to
dprintf() with the exception that it doesn't write anything to the
syslog. The reason is that syslog_write() releases a semaphore and can
therefore not be invoked when the thread spinlock is held.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22428 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf1539e1 06-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added debug macros ASSERT_ALWAYS_PRINT and ASSERT_PRINT which take
additional parameters that are fed into a dprintf() before panic() is
invoked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de52a13a 22-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

Unconditionally enable all ASSERTs in the kernel for now; should obviously
be turned off for non-development releases later :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21691 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9788912 20-Jun-2007 Travis Geiselbrecht <geist@foobox.com>

re-enable kernel asserts.
Disabled by default, but all kernel devs are *highly* recommended to turn them on for your builds and see if it trips anything, and then fix it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21477 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f51fb469 03-Apr-2006 Michael Lotz <mmlr@mlotz.ch>

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


# 92447917 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented on screen debug output during boot - to be enabled in the boot loader
safemode menu.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2ed21b85 12-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Some work in progress of the MTRR support. Shouldn't do any harm yet :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15525 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67a71026 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a pretty fatal bug in the page fault handling: interrupts were enabled
even if "kernel_startup" was "true". Page faults are now no longer allowed
during kernel startup (and could be easily avoided). The only situation where
we accept page faults with interrupts turned off now is during a kernel debugger
session.
Added a command debug_debugger_running() to test for that situation.
kernel_debugger() no longer sets kernel_startup while it's running; there should
be no situation when this could be helpful.
Interrupts are no longer enabled when a page fault happens in the kernel
debugger.
This potentially fixes all sorts of problems, and not only in the kernel debugger,
it could also have affected SMP (will test later).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14045 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed65cbe3 02-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The kernel debugger no longer uses dprintf() but kprintf() when printing
(dprintf() locks using acquire_spinlock() which can itself drop into the
kernel debugger, causing an endless loop (until the stack was full).
Removed debug_putchar().
The gdb interface is now calling arch_debug_serial_*() directly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13882 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f33c8020 29-May-2005 Axel Dörfler <axeld@pinc-software.de>

Removed debug/console.c, we no longer need it. frame_buffer_console_init() is now
called by debug_init_post_vm().
Since the availability of a blue screen specific getchar() is static anyway, there
is no need for the sBlueScreenGetChar variable (only the message "only serial input
available" gets lost, but since that is platform specific anyway...).
Hello blue screen! We now have an on-screen KDL, to be enabled by the kernel
setting "bluescreen", just like on BeOS.
The blue screen does not yet support any cursor actions or backspace, though (need
to grab some stuff from our console driver).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12896 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a63135f 29-May-2005 Axel Dörfler <axeld@pinc-software.de>

Cleanup of the debug stuff, prepared for blue screen debugging.
kernel_debugger() didn't do enough before; panic() did all the work - but
since the former is a public function as well, I moved all the functionality
to it. Also fixed a possible buffer overrun in panic().
Renamed dbg_* to debug_*.
"serial_debug_port" setting did not ignore negative values.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74b043d9 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Removed execute property that was set accidently (since CVS days).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11896 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0d8e689 20-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

Renamed some more init2 routines to init_post_vm() to make it clearer when
and why they are called.
Introduced a cpu_init_post_vm() that will now call arch_init_post_vm() instead
of letting main() doing it.
Fixed some return types (mostly from int to status_t).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9438 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adbaa781 18-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now B_MAX_CPU_COUNT rather than SMP_MAX_CPUS.
Removed unused headers.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7608 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9289abf0 13-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Added _kern_debug_output() syscall.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5353 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d78db8f 10-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Removed B_KDEBUG_* definitions; they are already part of KernelExport.h.
dbg_register_file[][] reserves now space for SMP_MAX_CPUS CPUs.
Removed old dbg_{set|get}_serial_debug() functions.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5308 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 564cba31 03-May-2003 Axel Dörfler <axeld@pinc-software.de>

Some header work: removed unnecessary dependencies to stage2.h, fixed
some broken C++ export definitions, added missing licenses etc.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3152 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60d9ed9e 28-Nov-2002 beveloper <beveloper@nowhere.fake>

fixed the ASSERT macro, it did not even compile if DEBUG was defined


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2102 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5cdacbaa 26-Oct-2002 lillo <lillo@nowhere.fake>

*LOTS* of small changes to make the kernel compatible with Be's KernelExport.h


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1683 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b5d1dc4 18-Jul-2002 Axel Dörfler <axeld@pinc-software.de>

Added the preliminary ASSERT() macro from NewOS.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@310 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b333c3b 17-Jul-2002 Philippe Houdoin <philippe.houdoin@gmail.com>

dbg_add_command() changed into BeOS compatible add_debugger_command().
remove_debugger_command() added.
Fix cmd_gdb() prototype according to new debugger command one.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@290 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4bf862e3689b034d4e44cf94c5e50fe7ae05aee3 21-Apr-2015 Axel Dörfler <axeld@pinc-software.de>

syslog_daemon: Converted to BServer.

* Instead of letting the kernel search for the syslog port, the
daemon now registers itself with the kernel (which even solves
a TODO).
* A port is created for the actual log messages from the launch_daemon,
and used on start.
* However, the SyslogTest does not yet work, due to the BMessage <->
KMessage communication problems.


# 97ac7257f656cba2ffba7fcefae6cad0cd41efb6 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
Add helper macros for placing markers in the source, so we can get the
address ranges of code we're interested in.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43071 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d80c86e19e2610e7444a4fcefe3e0f8e6 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f498c07968c2ed1cac7f83a95cee48269b53c8ea 10-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added STATIC_ASSERT() macro (from <Debug.h>, which cannot be included in the
kernel).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37087 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c8fcd770ae49ca577c4b308549889c49f9f7807 05-May-2010 Axel Dörfler <axeld@pinc-software.de>

* Moved the addition of the basic debugger commands directly after the VM init.
* Separated the other stuff previously done in debug_init_post_vm() to the new
debug_init_post_settings().
* Removed superfluous status_t return codes - they are ignored, anyway, and if
there really is a show stopper in the init process, panicking would be the
thing one should do.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3676b54bfd2e06b73646d1846b2ab0272cb96e2 13-Apr-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added vm_debug_copy_page_memory() which copies memory from a potentially not
mapped page.
* debug_{mem,strl}cpy():
- Added "team" parameter for specifying the address space the address are
to be interpreted in.
- When the standard memcpy() (with fault handler) fails, fall back to
vm_debug_copy_page_memory().
* Added debug_is_debugged_team(): Predicate returning true, if the supplied
team_id refers to the same team debug_get_debugged_thread() belongs to.
* Added DebuggedThreadSetter class for scope-based debug_set_debugged_thread().
Made use of it in several debugger functions.
* print_demangled_call() (x86): Fixed unsafe memory access.

Allows KDL stack traces to work correctly again, even if the page daemon has
already unmapped the concerned pages.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36230 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cfefeee3f81bd3ed97243986cdd6bf710d16d0bc 18-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed arch_debug_save_registers() to take an arch-specific structure
arch_debug_registers instead.
* Call arch_debug_save_registers() on all CPUs when entering the kernel
debugger.
* Added debug_get_debug_registers() to return a specified CPU's saved
registers.
* x86:
- Replaced the previous arch_debug_save_registers() implementation. Disabled
getting the registers via the gdb interface for the time being.
- Fixed the "sc", "call", and "calling" commands to also work for threads
running on another CPU.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8b522fcfe6f43aa27eaceff59446a362f336a227 20-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed ASSERT_[ALWAYS_]PRINT() to add the additional output to the panic()
message instead of printing it before calling panic().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be51dd0f4c69e723129015002d33b68ef5e0b14a 30-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added debug_strlcpy() for use in the kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33380 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea2abd110bd6a4518a954477562e2dd94a5fef9d 02-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of
ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of
two anyway and this implementation works for other numbers as well.
* The thread::fault_handler use in C[++] code was broken with gcc 4. At least
when other functions were invoked. Trying to trick the compiler wasn't a
particularly good idea anyway, since the next compiler version could break
the trick again. So the general policy is to use the fault handlers only in
assembly code where we have full control. Changed that for x86 (save for the
vm86 mode, which has a similar mechanism), but not for the other
architectures.
* Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer
fields in the cpu_ent structure, which must be used instead of
thread::fault_handler in the kernel debugger. Consequently user_memcpy() must
not be used in the kernel debugger either. Introduced a debug_memcpy()
instead.
* Introduced debug_call_with_fault_handler() function which calls a function
in a setjmp() and fault handler context. The architecture specific backend
arch_debug_call_with_fault_handler() has only been implemented for x86 yet.
* Introduced debug_is_kernel_memory_accessible() for use in the kernel
debugger. It determines whether a range of memory can be accessed in the
way specified. The architecture specific back end
arch_vm_translation_map_is_kernel_page_accessible() has only been implemented
for x86 yet.
* Added arch_debug_unset_current_thread() (only implemented for x86) to unset
the current thread pointer in the kernel debugger. When entering the kernel
debugger we do some basic sanity checks of the currently set thread structure
and unset it, if they fail. This allows certain commands (most importantly
the stack trace command) to avoid accessing the thread structure.
* x86: When handling a double fault, we do now install a special handler for
page faults. This allows us to gracefully catch faulting commands, even if
e.g. the thread structure is toast.

We are now in much better shape to deal with double faults. Hopefully avoiding
the triple faults that some people have been experiencing on their hardware
and ideally even allowing to use the kernel debugger normally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32073 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 671a2442d93f46c5343ef34e01306befa760c16a 31-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

More work towards making our double fault handler less triple fault prone:
* SMP:
- Added smp_send_broadcast_ici_interrupts_disabled(), which is basically
equivalent to smp_send_broadcast_ici(), but is only called with interrupts
disabled and gets the CPU index, so it doesn't have to use
smp_get_current_cpu() (which dereferences the current thread).
- Added cpu index parameter to smp_intercpu_int_handler().
* x86:
- arch_int.c -> arch_int.cpp
- Set up an IDT per CPU. We were using a single IDT for all CPUs, but that
can't work, since we need different tasks for the double fault interrupt
vector.
- Set the per CPU double fault task gates correctly.
- Renamed set_intr_gate() to set_interrupt_gate and set_system_gate() to
set_trap_gate() and documented them a bit.
- Renamed double_fault_exception() x86_double_fault_exception() and fixed
it not to use smp_get_current_cpu(). Instead we have the new
x86_double_fault_get_cpu() that deducts the CPU index from the used stack.
- Fixed the double_fault interrupt handler: It no longer calls int_bottom to
avoid accessing the current thread.
* debug.cpp:
- Introduced explicit debug_double_fault() to enter the kernel debugger from
a double fault handler.
- Avoid using smp_get_current_cpu().
- Don't use kprintf() before sDebuggerOnCPU is set. Otherwise
acquire_spinlock() is invoked by arch_debug_serial_puts().

Things look a bit better when the current thread pointer is broken -- we run
into kernel_debugger_loop() and successfully print the "Welcome to KDL"
message -- but we still dereference the thread pointer afterwards, so that we
don't get a usable kernel debugger yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32050 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 213d2d8f9dc09656dd2c20cfa36f96d6d53a4f07 29-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added syscall _kern_kernel_debugger() to enter the kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31965 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c755ecfe9626d075350b9d8e9fd4b3a025d4f3e8 20-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Added an emergency key mechanism to the kernel, inspired by Jan Klötzke's
patch from about a year ago (I couldn't use any code of his yet, though,
but there are a few things left). The emergency keys are triggered by
pressing Alt-SysReq + key.
* By default, only Alt-SysReq+'d' is used as a means to deliberately enter
the kernel debugger. F12 belongs to userland again, now :-)
* Debugger add-ons now have another optional method to implement their own
emergency keys - 'd' for the debugger cannot be overridden, though.
* The mechanism can be turned off via a new kernel setting, so it's not that
easy anymore to "crash" Haiku if you don't want to.
* Right now, the PS/2 driver, and the pre-input_server in-kernel debugger
keyboard mini-driver support this, USB not yet.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b9d5a2ec9b28fb9d787dc264e8903a4dbc3fb55 10-Mar-2009 Michael Lotz <mmlr@mlotz.ch>

* Add has_debugger_command() so whether or not a debugger command is available
can be checked.
* Make the usb_keyboard module check the presence of the needed debugger
commands to avoid the error messages in case of them being unavailable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29472 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eba063647cc4ff5aa863e1b5dc5093c22a3acb0 22-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Added simplified possibility to schedule UHCI transfers from within KDL.
* Added debugger commands to resolve usb_ids to pipes.
* Adjusted the physical memory allocator to be usable in a slimmed down mode
when running inside the kernel debugger.
* Implemented USB keyboard support for KDL through a kernel debugger add-on.
* Added kgetc() and made use of it where previously individual methods were used
to ensure that reading characters always goes through the kernel debugger
add-ons and the other methods.

This has some preconditions to meet though:
1) The keyboard must be in the boot protocol (currently the case but needs to
be revisited once we have a full usb_hid).
2) The keyboard must be attached to a UHCI root port (i.e. not use EHCI or OHCI,
also not through hubs unless those are USB 1.1).
3) the usb_hid driver has to be opened for this to work. This means that for the
time between initializing USB and when usb_hid is opened by the input_server
there is no keyboard support.

Also note that this has no way of detecting hot-plug, meaning that you can't
re-attach your USB keyboard from the hub to the root port once in KDL.

On the bright side of things, since this is a non-destructive mechanism it is
possible to enter and leave KDL without loosing the USB state.

Tested OK in QEMU, not tested on real hardware yet, will see in a few minutes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1894a0a98b5b2102f83c00b7273ba7654334f469 20-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Consistently use KDEBUG. It is always defined and therefore must be
checked with "#if".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ab39de9895775d10669a1a85ce3ff60b1ca7b55 17-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed unused SMP_MSG_RESCHEDULE ICI message.
* Introduced flag "invoke_scheduler" in the per CPU structure. It is
evaluated in hardware_interrupt() (x86 only ATM).
* Introduced SMP_MSG_RESCHEDULE_IF_IDLE message, which enters the
scheduler when the CPU currently runs an idle thread.
* Don't do dprintf() "CPU x halted!" when handling a SMP_MSG_CPU_HALT
ICI message. It uses nested spinlocks and could thus potentially
deadlock itself (acquire_spinlock() processes ICI messages, so it
could already hold one of the locks). This is a pretty likely scenario
on machines with more than two CPUs, but is also possible when the
panic()ing thread holds the threads spinlock. Probably fixes #2572.
* Reworked the way the kernel debugger is entered and added a "cpu"
command that allows switching the CPU once in KDL. It is thus possible
to get a stack trace of the thread not on the panic()ing CPU.
* When a thread is added to the run queue, we do now check, if another
CPU is idle and ask it to reschedule, if it is. Before this change, the
CPU was continuing to idle until the quantum of the idle thread
expired. Speeds up the libbe.so build about 8% on my machine (haven't
tested the full Haiku image build yet).
* When spinlock debugging is enabled (DEBUG_SPINLOCKS) we also record
the spinlock acquirer on non-smp machines. Added "spinlock" debugger
command to get the info.
* Added debugger commands "ici" and "ici_message", printing info on
pending ICI message respectively on a given one.
* Process not only a single ICI message in acquire_spinlock() and other
places, but all pending ones.
* Also process ICI messages when waiting for a free one -- avoids a
potential deadlock.
* Mask out non-existing CPUs in send_multicast_ici(). panic() instead of
just returning when there's no target CPU left.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 945a6a41acb998632f3bdfebaa5d666db2ff4df5 15-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

bonefish + mmlr:
* Add possibility to restart a complete pipe through B_KDEBUG_RESTART_PIPE.
* Implement tail in the kernel debugger making use of the former.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ddecb4a7da1e8c56af7f319cbb26f5e47e65f6f6 12-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the way the demangle functionality works: instead of having a kernel
debugger add-on set a demangle hook, all modules under debugger/demangle/ are
now considered demangle modules.
* Added another function to the demangle module interface that gives you access
to the arguments.
* Implemented a demangling module for GCC2.
* The older demangling module is now called "gcc3+", but doesn't support
getting the arguments yet.
* The "call" KDL command is now using demangling to automatically show you
the arguments of a call from a stack crawl.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28018 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8bdc2443da0549194191804a80479ee7fd4531a 01-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Created a central place for putting kernel debug enabling macros.
Currently it only contains KDEBUG and the block cache debugging macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 290e3dd2281d8484acd712bf51137978e7836ecd 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduced the notion of a currently debugged thread in the kernel
debugger and added respective getter/setter methods
debug_{get,set}_debugged_thread(). By default the currently debugged
thread is the thread that dropped into the kernel debugger, but commands
like "in_context" can change it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27164 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0deddbe36cb079a7fa92a7757df4347be9d8b2f2 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function parse_next_debug_command_argument(), which parses the
first command line argument of a given command line string.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27155 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 46ec23016212f35b99bc1ba02b7421eb287033e1 12-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

When in the kernel debugger we do now record the relevant information
(fault address, pc, read/write) when a page fault occurs, and print them
in case this caused the termination of a debugger command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8881176ff3ff0a868ebf53e25858864153edfc9f 23-Jul-2008 François Revol <revol@free.fr>

A module that hooks into the debugger to provide it with a demangle() so at least when using C++ in the kernel stack crawls are meaningful.
It does its job by using part of libsupc++, with fake malloc and friends to make sure it won't double fault.
Works here, but cp-demangle must be extracted by hand from the lib, can't get the rule to work as I want, Ingo ?
Maybe using it directly without malloc hack would be ok with 16KB buffer, but I'm not sure of that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26581 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eb0dca1d333cb8cf0045ae68b98616e01f25c365 17-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Add a KDEBUG_ONLY macro for easier handling of code only needed in case of KDEBUG.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26483 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73aa393d737b25eb29a5200d5f6e6340000affee 31-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced pipes in the kernel debugger. The syntax is similar to
pipes in the shell, though the semantics is a little different: The
second command is invoked whenever the first command has written a
complete line. The line is passed as last argument to the second
command. The new command flag B_KDEBUG_PIPE_FINAL_RERUN causes the
second command to be invoked again (with NULL argument) after the
first command is done.
* Added kprintf_unfiltered() and kputs_unfiltered() which bypass the
pipe mechanism and directly print to the bluescreen/serial output.
* Moved most commands from debug.cpp to the new
debug_builtin_commands.cpp.
* B_KDEBUG_DONT_PARSE_ARGUMENTS commands don't get an argument anymore,
if it would consist of white space only.
* Added new debugger command return value B_KDEBUG_ERROR, which
indicates that executing the command failed. This return code will
abort a complete pipe.
* Since debugger commands can nest (i.e. one command can invoke another
one) the setjmp()/longjmp() mechanism to restore the stack after a
page fault in a command needs more than one jump buffer.
* Added abort_debugger_command(), which longjmp()s out of the currently
executed command. This will also abort the current pipe.
* When pagination is enabled pressing "a" will abort the running command
(as opposed to "q" which only disables the blue screen output, but
lets the command continue).
* Added debugger commands:
- "grep" which can be used to filter output by pattern. Removed the
"filter" command and the underlying mechanism that did that before.
- "head" which prints only the first lines of output of another
command.
- "wc" counts lines, words, and characters of another command's
output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25744 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a886f802fca0b7d6c6e2bb4b790d8865c1807bff 20-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added debug_screen_output_enabled() function.
* The boot splash code now checks wether debug screen output is enabled or not
using the above function.
* The boot splash code no longer maps it's own copy of the frame buffer, instead,
it will use the boot item feature as the VESA driver does. Also removed the
lock, as that's not needed at all.
* Renamed splash.cpp to boot_splash.cpp, and boot/splash.h to boot_splash.h
(it's not part of the boot loader, but the kernel).
* Removed dead code from boot_splash.cpp, added license. Replaced license
header in boot_splash.h to a style guide conforming one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24489 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f3937521f427f5882b8f865fc0e4961325ae04d 21-Feb-2008 François Revol <revol@free.fr>

Add debugger module hooks to implement alternative io (I need laplink debugging...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24052 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cec75dc33dd1cda148e057d91b48989f6f3a0c1 30-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Debugger modules now have two methods: enter_debugger() and exit_debugger().
* The kernel now opens up to 8 debugger modules (and puts them into an array;
maybe we'll want to switch to a doubly linked list when there is the need).
* Implemented an example debugger module that prints a stack trace of the
current thread when the kernel debugger is entered (not included in the
image).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 325b88a661bd51702cf70ec96dc1974de429b258 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced debugger command flag B_KDEBUG_DONT_PARSE_ARGUMENTS.
For commands with this flag set, the parser won't parse the
arguments provided (it will only check for matching parentheses and
brackets), but will pass the unparsed argument list string to the
command instead.
* Set the new flag for the "expr" command, so one doesn't have to quote
the expression to evaluate anymore (or put it in parentheses).
* Fixed tokenizing of quoted and unquoted strings in expression mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23697 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 902425896d6b7f001f68d54708884e2727b837fc 20-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made kputs() available in the kernel and used it for printing debugger
command usage texts, which can be too long for kprintf().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a90d12e268b539b26b461a9e4e2560acdf91e2b 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added add_debugger_command_etc() which is similar to
add_debugger_command(), but additionally takes parameters "usage"
and "flags".
* Added add_debugger_command_alias() which creates another name for an
existing command.
* Added print_debugger_command_usage() to print a command's usage.
* invoke_debugger_command() intercepts invocations with "--help" and
prints the command's usage text, if it is known. If unknown, the
command will be called normally.
* Made use of the new functions in debug.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23573 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 06f78e9fb73f0043707c177e03b976a4f94115c9 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way temporary variables work. They won't be unset before
a command is executed anymore. Instead the least recently used
temporary variable is overwritten, if there's no free slot for a new
temporary variable.
* Removed the special handling for the command result variable ("_"). It
just works like any other temporary variable, now.
* Individual temporary variables can be removed (e.g. using the "unset"
command).
* Added unset_all_debug_variables() and "unset_all" command to unset
all persistent and temporary variables.
* Removed remove_all_temporary_debug_variables and renamed
remove_debug_variable() to unset_debug_variable().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b4fa1664e6fb9ba781ee509bf725774937eeaeb 15-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented parse_expression(). The back-end is an expression parser
that is a little more powerful than BeOS'. It features:
- Persistent and temporary uint64 variables. The former kind is set
only by the user. The latter (those prefixed "_") can be set
automatically by commands, thus e.g. making it easier to access
members of a dumped structure. They are unset when the next command
is invoked. The special temporary variable "_" is defined as a
command's return value.
- Expressions can contain nested command invocations using brackets
("[ ... ]").
- Command lines are parsed by the expression parser, too. They can
contain command invocations (in brackets) and expressions (in
parentheses).
* Added debugger commands:
- expr: Evaluates the given expression and prints the result.
- unset: Undefines a variable.
- vars: Prints the values of all defined variables.
* Moved debugger command code into its own source file.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 76ab7bdcf8b00882b67a39c6566377aee30dd201 03-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function dprintf_no_syslog(). It is basically equivalent to
dprintf() with the exception that it doesn't write anything to the
syslog. The reason is that syslog_write() releases a semaphore and can
therefore not be invoked when the thread spinlock is held.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22428 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf1539e1a3e3cae037b8bc7cecc1c206935313f1 06-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added debug macros ASSERT_ALWAYS_PRINT and ASSERT_PRINT which take
additional parameters that are fed into a dprintf() before panic() is
invoked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de52a13af7522289b19770e66d8e4793197239b8 22-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

Unconditionally enable all ASSERTs in the kernel for now; should obviously
be turned off for non-development releases later :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21691 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9788912f06232a93e07eae4483f8da39ea155c7 20-Jun-2007 Travis Geiselbrecht <geist@foobox.com>

re-enable kernel asserts.
Disabled by default, but all kernel devs are *highly* recommended to turn them on for your builds and see if it trips anything, and then fix it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21477 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f51fb4696c63d368e8444fb9baa9126caf7b0d4c 03-Apr-2006 Michael Lotz <mmlr@mlotz.ch>

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


# 924479179b8e0792397a804dccfefb9947ea04cd 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented on screen debug output during boot - to be enabled in the boot loader
safemode menu.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2ed21b85257d9d36d4d8a25c2a798a42add6e618 12-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Some work in progress of the MTRR support. Shouldn't do any harm yet :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15525 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67a71026584e7eb5d0b920e19c49918209ad72cb 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a pretty fatal bug in the page fault handling: interrupts were enabled
even if "kernel_startup" was "true". Page faults are now no longer allowed
during kernel startup (and could be easily avoided). The only situation where
we accept page faults with interrupts turned off now is during a kernel debugger
session.
Added a command debug_debugger_running() to test for that situation.
kernel_debugger() no longer sets kernel_startup while it's running; there should
be no situation when this could be helpful.
Interrupts are no longer enabled when a page fault happens in the kernel
debugger.
This potentially fixes all sorts of problems, and not only in the kernel debugger,
it could also have affected SMP (will test later).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14045 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed65cbe34940dd08efe54269304daa29e0155535 02-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The kernel debugger no longer uses dprintf() but kprintf() when printing
(dprintf() locks using acquire_spinlock() which can itself drop into the
kernel debugger, causing an endless loop (until the stack was full).
Removed debug_putchar().
The gdb interface is now calling arch_debug_serial_*() directly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13882 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f33c8020e2693795032110c933cbb60dea5be8df 29-May-2005 Axel Dörfler <axeld@pinc-software.de>

Removed debug/console.c, we no longer need it. frame_buffer_console_init() is now
called by debug_init_post_vm().
Since the availability of a blue screen specific getchar() is static anyway, there
is no need for the sBlueScreenGetChar variable (only the message "only serial input
available" gets lost, but since that is platform specific anyway...).
Hello blue screen! We now have an on-screen KDL, to be enabled by the kernel
setting "bluescreen", just like on BeOS.
The blue screen does not yet support any cursor actions or backspace, though (need
to grab some stuff from our console driver).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12896 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a63135f7c8ef1cbcb0893a118d4f4349c8f29c8 29-May-2005 Axel Dörfler <axeld@pinc-software.de>

Cleanup of the debug stuff, prepared for blue screen debugging.
kernel_debugger() didn't do enough before; panic() did all the work - but
since the former is a public function as well, I moved all the functionality
to it. Also fixed a possible buffer overrun in panic().
Renamed dbg_* to debug_*.
"serial_debug_port" setting did not ignore negative values.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74b043d98d35652a6892fc430537a02f5f9d9f76 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Removed execute property that was set accidently (since CVS days).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11896 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0d8e689acb4ec1fbe798773cfb066277c7d4f9b 20-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

Renamed some more init2 routines to init_post_vm() to make it clearer when
and why they are called.
Introduced a cpu_init_post_vm() that will now call arch_init_post_vm() instead
of letting main() doing it.
Fixed some return types (mostly from int to status_t).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9438 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adbaa7817ebf2e9ceb60e6edae8bac7f58f05bca 18-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now B_MAX_CPU_COUNT rather than SMP_MAX_CPUS.
Removed unused headers.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7608 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9289abf0e4582ef95a10c2de36b3db664fc3365c 13-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Added _kern_debug_output() syscall.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5353 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d78db8f17d62c11182f0da539d8f049995ff4f7 10-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Removed B_KDEBUG_* definitions; they are already part of KernelExport.h.
dbg_register_file[][] reserves now space for SMP_MAX_CPUS CPUs.
Removed old dbg_{set|get}_serial_debug() functions.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5308 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 564cba312ebe49860fbb8416737c4de3e6ccd5f2 03-May-2003 Axel Dörfler <axeld@pinc-software.de>

Some header work: removed unnecessary dependencies to stage2.h, fixed
some broken C++ export definitions, added missing licenses etc.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3152 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60d9ed9e3b14ed09a9c8026872d2c9ae907e8335 28-Nov-2002 beveloper <beveloper@nowhere.fake>

fixed the ASSERT macro, it did not even compile if DEBUG was defined


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2102 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5cdacbaabbd66673ada83b4d97d87126776484dc 26-Oct-2002 lillo <lillo@nowhere.fake>

*LOTS* of small changes to make the kernel compatible with Be's KernelExport.h


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1683 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b5d1dc418a323b3969eb6fc5a62335ffb51db8b 18-Jul-2002 Axel Dörfler <axeld@pinc-software.de>

Added the preliminary ASSERT() macro from NewOS.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@310 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b333c3bd1e6634194acd795e4b9abe49c8d12e0 17-Jul-2002 Philippe Houdoin <philippe.houdoin@gmail.com>

dbg_add_command() changed into BeOS compatible add_debugger_command().
remove_debugger_command() added.
Fix cmd_gdb() prototype according to new debugger command one.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@290 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96