History log of /haiku/src/system/kernel/debug/debug_parser.cpp
Revision Date Author Comments
# 82272ada 18-Aug-2023 Joachim Mairböck <j.mairboeck@gmail.com>

kernel debugger: add missing newline to exception messages without position

This is the case, for example, for the "out of memory for command execution"
message.

Change-Id: I0951a91c7a9fcdd1730a0441d7fac0eb6e608615
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6843
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 294711f9 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


# 4be4fc6b 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 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


# 6365627b 17-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for giving multiple kernel debugger commands in a single
line, separated by ";".
* Fixed incorrect parsing when "|" was not separated by a space from the
previous argument.


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


# e0aad96f 22-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Allow to use symbols as variables (prefixed with '@'). Now only tab completion
for variable names is missing B-}


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33723 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


# 360d4974 02-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced the temporary storage used in the kernel debug command parser. We now
have a simple dedicated heap for the kernel debugger with stacked allocation
pools (deleting a pool frees all memory allocated in it). The heap should
eventually be used for all commands that need temporary storage too large for
the stack instead of each using its own static buffer.


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


# b9f431f1 24-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Extended debugger language: Dereferenced addresses are now supported as
left hand side of assignments. IOW it is possible to modify memory, now.


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


# 18f2a9c1 24-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for architecture specific debug variables, e.g. for
referencing iframe registers. Their prefix is "$". E.g. "$eax" refers to
the eax register of the current iframe. The features cooperates with the
"in_context" command, i.e. "in_context 92 $eip = 0" will set the eip
register of thread 92 to 0 (thus sealing its fate ;-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27192 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


# 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


# 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


# 0bf73dd2 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Increased the maximum number of command line arguments to a more
comfortable number. Somewhat more complex "traced" filter expressions
tended to exceed the old limit easily.


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


# 42a5ea09 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Oops, "f" is a hex digit, too. Hex numbers with "f" in them work again
in the kernel debugger.


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


# b9074efc 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the "vnodes" KDL command when called without any arguments.
* Fixed the usage text of the "help" KDL command.
* Made the "ambiguous command" warning shorter, so that it will still fit in
the exception buffer.


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


# 5c62817c 15-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added unary "*" operator for dereferencing addresses to the
debugger expression language. By default it reads a uint32 value.
Another target size (1, 2, 4, or 8 bytes) can be specified in braces
after the "*" (e.g. "*{2}address" for uint16).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23551 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


# 294711f98c107cf2d9d05b7fc34cd863e87bd358 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


# 4be4fc6b1faddbd037146214a0011d320842b4f3 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 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


# 6365627b33ba488d7df657c2badc67261454f548 17-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for giving multiple kernel debugger commands in a single
line, separated by ";".
* Fixed incorrect parsing when "|" was not separated by a space from the
previous argument.


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


# e0aad96f945323bdabadd6a91a2cddd5985bbe5f 22-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Allow to use symbols as variables (prefixed with '@'). Now only tab completion
for variable names is missing B-}


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33723 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


# 360d4974b96a6821dbf4b31e0662bfcd31f713bc 02-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced the temporary storage used in the kernel debug command parser. We now
have a simple dedicated heap for the kernel debugger with stacked allocation
pools (deleting a pool frees all memory allocated in it). The heap should
eventually be used for all commands that need temporary storage too large for
the stack instead of each using its own static buffer.


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


# b9f431f1dfbf3c1b5d3c4b282cbec7210fd5110c 24-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Extended debugger language: Dereferenced addresses are now supported as
left hand side of assignments. IOW it is possible to modify memory, now.


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


# 18f2a9c17d2b2439b9acbcca4cf99069b9b17e6e 24-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for architecture specific debug variables, e.g. for
referencing iframe registers. Their prefix is "$". E.g. "$eax" refers to
the eax register of the current iframe. The features cooperates with the
"in_context" command, i.e. "in_context 92 $eip = 0" will set the eip
register of thread 92 to 0 (thus sealing its fate ;-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27192 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


# 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


# 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


# 0bf73dd2f1fe982d78a99dff84e81ea577411bc6 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Increased the maximum number of command line arguments to a more
comfortable number. Somewhat more complex "traced" filter expressions
tended to exceed the old limit easily.


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


# 42a5ea091ac302707e6b0db917f75931200560dc 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Oops, "f" is a hex digit, too. Hex numbers with "f" in them work again
in the kernel debugger.


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


# b9074efcb78d914f902047cc8410532d42ce7bbb 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the "vnodes" KDL command when called without any arguments.
* Fixed the usage text of the "help" KDL command.
* Made the "ambiguous command" warning shorter, so that it will still fit in
the exception buffer.


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


# 5c62817c6febbd444bf64b8652d211bbf81d7ff4 15-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added unary "*" operator for dereferencing addresses to the
debugger expression language. By default it reads a uint32 value.
Another target size (1, 2, 4, or 8 bytes) can be specified in braces
after the "*" (e.g. "*{2}address" for uint16).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23551 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