History log of /haiku/src/system/kernel/arch/x86/arch_debug.cpp
Revision Date Author Comments
# ef9e2f62 22-Sep-2023 Augustin Cavalier <waddlesplash@gmail.com>

kernel/arch: Make arch_debug_get_caller() a macro implemented by a builtin.

Only the x86 and PPC implementations look like they would have worked,
while the builtin is available and will work across all architectures.
We already use it unconditionally in some parts of libroot.

Change-Id: I2dffb3b2c7cdd605092382b9d649151adb921bb4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6942
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 425ac1b6 20-Jun-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

refactor: Swap %Ld for %lld in all format usages

* %Ld is an undocumented alias for %lld in glibc.
* muslc doesn't implement it for this reason.
* While we will likely never drop %Ld support,
lets clean house and set a better example.

Change-Id: Id46dad3104abae483e80cc5c05d1464d3ecd8030
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6636
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 3a3d6c4a 02-Sep-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/x86: Check the frame address really is a user address before copying.

On x86_64, it is possible for a frame address to be in non-canonical
form (i.e. have bits 48-63 not all zero) if one writes hand-generated
assembly which does not use registers for their intended purpose, as
there is no processor requirement about the contents of those registers
or stack portions except when using "ret" or similar such instructions.

As it turns out, OpenSSL's libcrypto has such hand-generated assembly
for cryptography routines; so on 64-bit this caused a GPE when running
the profiler on applications that used OpenSSL.

Fixes #14530.


# 20f6556b 16-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/x86: Backslash-escape trigraphs.

Fixes an instance of -Wtrigraphs.


# 513403d4 14-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert team and thread changes for COMPAT_MODE (hrev52010 & hrev52011).

This reverts commit c558f9c8fe54bc14515aa62bac7826271289f0e4.
This reverts commit 44f24718b1505e8d9c75e00e59f2f471a79b5f56.
This reverts commit a69cb330301c4d697daae57e6019a307f285043e.
This reverts commit 951182620e297d10af7fdcfe32f2b04d56086ae9.

There have been multiple reports that these changes break mounting NTFS partitions
(on all systems, see #14204), and shutting down (on certain systems, see #12405.)
Until they can be fixed, they are being backed out.


# c558f9c8 21-May-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86_64: stacktrace for threads in compatibility mode.

* add compat_stack_frame struct.
* user symbols are't yet looked up in compatibility mode.

Change-Id: I94b45f25564c246bb174f9491f4abc4aa8676549


# b2ef1767 17-Oct-2016 Julian Harnath <julian.harnath@rwth-aachen.de>

x86 kernel stack trace: make sure memcpy stays in bounds

* Commit 337c4ccf introduced usage of plain memcpy in
get_next_frame_no_debugger(), when the frame is already
known to be on the kernel stack. However, it also needs
to check that the end of the frame is still within the
stack bounds. Otherwise this can cause a KDL if bp does
not point to a valid complete frame anymore and is
near a page boundary. Although with commit e477b10c such
cases should already be avoided, it's still safer to
check this here in case of e.g. analyzing broken stacks.


# e477b10c 17-Oct-2016 Julian Harnath <julian.harnath@rwth-aachen.de>

x86 kernel stack trace: break when return address is zero

* No need to continue walking the stack when a zero return
address is found, only bogus frames will follow

* Fixes KDLs seen when using the system profiler, due to
a bug that will be fixed in the next commit...


# 337c4ccf 23-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

kernel debugger: Use memcpy for stack trace on kernel stack.

If it was already determined that the memory is within the kernel
stack, a simple memcpy is enough.

This allows capturing kernel stack traces in situations where a fault
handler cannot be installed (i.e. where one is already installed).


# 9bf9ee38 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Whitespace and style cleanup only.


# 44ec21c3 29-May-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

ByteOrder.h: simplify compiler test

* A problem with our gcc requires adding casts for gcc4 when
the __builtin_bswap functions are used with a format string
* Unlike gcc2, the __builtin_bswap functions do not get disabled
despite using -fno-builtins, hence added compiler check in
runtime_loader/utility.cpp


# 735f6748 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Debugger can now use dr3


# 3756e0ac 29-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

kernel: use uint64 instead of int64 to avoid narrowing conversion warnings.

* gdb_register is used only in arch_debug.cpp


# 5afce632 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Demangle symbols in stack traces.

Since the demangle debugger extension now gets loaded when booting
from an image, use it in stack traces. Can't print argument values
like on x86, however, since x86_64 uses registers to pass the first
6 arguments rather than the stack we can't easily get to them.


# bcb07a31 13-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented the rest of the kernel debugger functions for x86_64.

Merged with the x86 implementations, mostly the same except for a
few differences. GDB stub is currently broken, will investigate
later.


# 7dc738b0 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed ordering of registers in arch_debug_gdb_get_registers.

Current code was sending EAX, EBX, ECX, EDX..., GDB (all versions as far
as I can tell) expects EAX, ECX, EDX, EBX... Also added missing FS and GS.


# b5c9d24a 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented threading for x86_64.

* Thread creation and switching is working fine, however threads do not yet
get interrupted because I've not implemented hardware interrupt handling
yet (I'll do that next).
* I've made some changes to struct iframe: I've removed the e/r prefixes
from the member names for both 32/64, so now they're just named ip, ax,
bp, etc. This makes it easier to write code that works with both 32/64
without having to deal with different iframe member names.


# 5e9bb17d 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Renamed remaining i386_* functions to x86_* for consistency.


# 15feb603 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 4e8fbfb2 03-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

x86_{read,write}_cr{0,4} can just be implemented as macros, put an x86_ prefix on the other read/write macros for consistency.


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


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


# 9536ec02 03-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Reimplemented the gdb stub support for the 'g' command (read registers):
* Added an arch_debug_gdb_get_registers() interface that is supposed to provide
the register values in the format expected by gdb and implemented it for x86.
* Reimplemented gdb_regreply() to use that. Also made it buffer overflow safe.


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


# e468e31f 04-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Added intermediate cast to addr_t before cast to pointer (CID 4717).


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


# 45bd7bb3 25-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed unnecessary inclusions of <boot/kernel_args.h> in private kernel
headers and respectively added includes in source files.


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


# 78dde7ab 04-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Consequently use uint32 for the physical page directory address.


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


# 147133b7 25-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* First run through the kernel's private parts to use phys_{addr,size}_t
where appropriate.
* Typedef'ed page_num_t to phys_addr_t and used it in more places in
vm_page.{h,cpp}.


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


# 23b7090f 31-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

is_calling(): Skip non-kernel addresses. Fixes the often not working
"calling" command.


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


# a38f8503 22-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* arch_debug_get_stack_trace():
- Replaced the "userOnly" parameter by a "flags" parameter, that allows to
specify kernel and userland stack traces individually.
- x86, m68k: Don't always skip the first frame as that prevents the caller
from being able to record its own address.
* capture_tracing_stack_trace(): Replaced the "userOnly" parameter by
"kernelOnly", since one is probably always interested in the kernel stack
trace, but might not want the userland stack trace.
* Added stack trace support for VM cache kernel tracing.


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


# fe30b74f 06-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix for stack traces in the early boot process: The thread might not have
its stack top/bottom assigned yet.


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


# bbd97b4b 03-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Made the VMArea fields base and size private and added accessors instead.
This makes it more explicit where the fields are modified.


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


# f34a1dd5 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Created VMArea.{h,cpp} and moved VMArea and the global area hash table (new
class VMAreaHash) there.


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


# e50cf876 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


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


# 90d870c1 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved VMAddressSpace definition to vm_address_space.h.
* "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions
into methods, made all attributes (but "areas") private, and added
accessors.
* Also turned the vm.cpp functions vm_area_lookup() and
remove_area_from_address_space() into VMAddressSpace methods. The rest of
the area management functionality will follow soon.


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


# a99eb6b5 01-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

vm_area -> VMArea


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


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

* "sc" and "call" will no longer ignore if they couldn't find the thread you
asked them for.


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


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

* Added an arch_debug_stack_trace() function that is called from the KDL loop
in case there aren't any KDL commands available yet.


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


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

Fixed incorrect uses of user_{strl,mem}cpy() in the kernel debugger. This could
break stack traces.


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


# 6a1f462e 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* arch_debug_get_interrupt_pc() does now optionally return whether the iframe
is a syscall iframe.
* User debugger support: Don't to call BreakpointManager::PrepareToContinue(),
if the thread returns from a syscall. We don't want to skip breakpoints in
that case.


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


# 7927ebb6 03-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the appending of '*'/'&' for pointer/reference parameters to the gcc 2
demangler, where it belongs. The gcc 4 stack traces look correct now.


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


# 813d6a74 03-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

print_demangled_call(): Use a heap allocated buffer. This allows us to be more
generous with the size.


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


# c33667d4 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Fixing warnings under GCC4 in preparation to enable -Werror there as well:
* Replaced the use of offsetof() for structs that aren't PODs. Add a
offset_of_member() macro to util/khash.h because that's what it's used for
in our cases.
* Change the signature of add_debugger_command()/remove_debugger_command() on
GCC > 2 to avoid the depricated conversion from string constants to char *.
* Adding some "suggested" parenthesis. I know that not everyone likes that, but
it pointed out at least one bug that is fixed here as well.


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


# 3a5a6775 31-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* print_demangled_call() now brings some color into your Haiku life (ie. to
the KDL sessions).


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


# 97ba3fb3 30-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Instead of faulting when trying to print an invalid string pointer,
print_demangled_call() will now use user_strlcpy() to copy the string
first (if that fails, it will printf '???' to show this).


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


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

* Factored out the demangled function call dump to a print_demangled_call().
* The stack_trace() command now also uses this call by default to give you
the arguments to all functions in a stack crawl (beware of templates for now,
though).
* Use the new option '-d' to disable the demangling. You can now also specify
'-d' in the "call" command which has the same meaning there.
* NULL pointers are now printed as "NULL", and NULL strings are printed as
well.


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


# 715fbb94 29-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

arch_debug_get_stack_trace(): We do want the return address of the last
skipped iframe. "profile" didn't capture the top-most function, unless
run with "-s 1".


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


# e670fc6f 15-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added new parameter "skipIframes" to arch_debug_get_stack_trace(). That
many iframes are supposed to be skipped before recording the stack
trace. Currently implemented for x86 only.


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


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

arch_debug_get_interrupt_pc() does now also support the currently
debugged thread, if set. This makes "dis" without specified address work
when used with "in_context".


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


# 0739b87e 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added arch_debug_get_interrupt_pc(), which is supposed to return the
PC of the innermost iframe.
* The "in_context" command does now set the currently debugged thread
respectively.


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


# 757f253a 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added "in_context" debugger command. It takes a thread ID and a command
line and executes the command line in the context of the specified
thread. E.g. "in_context <thread> db <addr>" allows to read memory from
a team that is not active ATM.


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


# 5ccf1db3 04-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Also print whether an iframe is a userland or kernel iframe.
* In case of a kernel iframe the iframe is shorter -- fixed the output
accordingly.


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


# bca3215f 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced x86_get_double_fault_stack(), which returns the address
and size of the double fault stack.
* is_kernel_stack_address() does now also check whether the given
address is on the double fault stack. This fixes stack traces on
double faults, which were broken (i.e. went only to the double fault
iframe) since we started checking whether the addresses are on the
kernel stack at all.


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


# e146a7bf 06-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Also print the indices of stack frames. This makes the "call" command
more convenient to use.


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


# a8f9741c 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

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


# ec09e0a8 21-May-2008 Axel Dörfler <axeld@pinc-software.de>

Patch by Jan Klötzke:
* For vm86 mode the kernel stack top is adjusted -> do not rely on the
kernel_stack_base + KERNEL_STACK_SIZE calculation.


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


# 4dd0a2c7 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added arch_debug_get_stack_trace() that can be used to get a stack trace
(the list of return addresses) for the current stack.


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


# ebe5326d 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


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


# 758962ec 26-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added arch_debug_contains_call() function that returns wether or not
a call chain contains a specific symbol (or address).
* Added a new KDL command "calling" that you can use to get a list of
threads that have a specific function in their call chain.
* Removed extraneous white space.


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


# 08f2fdac 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* "call" now sets some useful debugger variables, like _argX for all arguments,
and _frame for the stack frame.


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


# db18308b 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed the "call" command to actually show the arguments that belong to the
function name it prints.


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


# fad02fc2 28-Jan-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

Print thread ids in decimal.


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


# 2477bce5 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for userland symbol lookup in "sc" and "call". Having
used it for an hour or so, I really wonder how we could live without it.
:-)


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


# 1111ffc5 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

An outermost stack frame (having a NULL previous frame) was
incorrectly recognized as iframe. Fixes the read fault when doing "sc"
for a kernel thread.


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


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

* Added support for the "--help" argument to some debugger commands.
* The kernel debugger does now define some temporary variables when
entered (current thread and team, etc.).


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


# 34b3b26b 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



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


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

* Added a KDL function "call" that can show the arguments together with
a function in the stack trace (only works reliably when a stack frame
is exists, and you'll have to know the number of arguments).
* Refactored the functions a bit and extracted setup_for_thread() out
of stack_trace() to be used by show_call() as well.


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


# e6dc7903 26-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* vm.h no longer includes vm_types.h - only those that actually need access
to the private VM types are including vm_types.h now.
* Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's
cleaner this way, and the actual types are only used in C++ files now,
anyway.
* And that caused changes in many files...
* Made commpage.h self-containing.
* Minor cleanup.


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


# 393fceb5 27-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up vm_types.h a bit, and made vm_page, vm_cache, and vm_area
opaque types for C.
* As a result, I've renamed some more source files to .cpp, and fixed
all warnings caused by that.


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


# 337c4ccf011eef6b9a5924142457d1c34a75e5f3 23-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

kernel debugger: Use memcpy for stack trace on kernel stack.

If it was already determined that the memory is within the kernel
stack, a simple memcpy is enough.

This allows capturing kernel stack traces in situations where a fault
handler cannot be installed (i.e. where one is already installed).


# 9bf9ee3806866886516cbe7b37dea5f8985c7186 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Whitespace and style cleanup only.


# 44ec21c3ff3eb22693333ad429b1972206223754 29-May-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

ByteOrder.h: simplify compiler test

* A problem with our gcc requires adding casts for gcc4 when
the __builtin_bswap functions are used with a format string
* Unlike gcc2, the __builtin_bswap functions do not get disabled
despite using -fno-builtins, hence added compiler check in
runtime_loader/utility.cpp


# 735f67481fa904ae6bb5d0763f515fd7b93d5529 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Debugger can now use dr3


# 3756e0ac38b6d15d6781d2590b1d0330f97903b5 29-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

kernel: use uint64 instead of int64 to avoid narrowing conversion warnings.

* gdb_register is used only in arch_debug.cpp


# 5afce632f385fe750150f4b05f567f0f980a888e 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Demangle symbols in stack traces.

Since the demangle debugger extension now gets loaded when booting
from an image, use it in stack traces. Can't print argument values
like on x86, however, since x86_64 uses registers to pass the first
6 arguments rather than the stack we can't easily get to them.


# bcb07a319b647eb0af60398e972525cc0a686aa9 13-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented the rest of the kernel debugger functions for x86_64.

Merged with the x86 implementations, mostly the same except for a
few differences. GDB stub is currently broken, will investigate
later.


# 7dc738b0fb075b6eedc27e1efddb5661c085c7d8 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed ordering of registers in arch_debug_gdb_get_registers.

Current code was sending EAX, EBX, ECX, EDX..., GDB (all versions as far
as I can tell) expects EAX, ECX, EDX, EBX... Also added missing FS and GS.


# b5c9d24abcc3599375153ed310b495ea944d46a0 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented threading for x86_64.

* Thread creation and switching is working fine, however threads do not yet
get interrupted because I've not implemented hardware interrupt handling
yet (I'll do that next).
* I've made some changes to struct iframe: I've removed the e/r prefixes
from the member names for both 32/64, so now they're just named ip, ax,
bp, etc. This makes it easier to write code that works with both 32/64
without having to deal with different iframe member names.


# 5e9bb17da7b9cdd76ff9072486fab90688cf8c36 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Renamed remaining i386_* functions to x86_* for consistency.


# 15feb60325be086823e80a3468f7aab2bfbc9f7d 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 4e8fbfb2d158de7b1cadd1c060acee51a7d67309 03-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

x86_{read,write}_cr{0,4} can just be implemented as macros, put an x86_ prefix on the other read/write macros for consistency.


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


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


# 9536ec02971d96e1941af928eb3645bc6e3133e3 03-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Reimplemented the gdb stub support for the 'g' command (read registers):
* Added an arch_debug_gdb_get_registers() interface that is supposed to provide
the register values in the format expected by gdb and implemented it for x86.
* Reimplemented gdb_regreply() to use that. Also made it buffer overflow safe.


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


# e468e31f7f4c11badcc4d35cbe21bd816f6d58e9 04-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Added intermediate cast to addr_t before cast to pointer (CID 4717).


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


# 45bd7bb3db9d9e4dcb02b89a3e7c2bf382c0a88c 25-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed unnecessary inclusions of <boot/kernel_args.h> in private kernel
headers and respectively added includes in source files.


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


# 78dde7abd76bad760d8d8e94908a19a0e583eb6a 04-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Consequently use uint32 for the physical page directory address.


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


# 147133b76cbb1603bdbff295505f5b830cb4e688 25-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* First run through the kernel's private parts to use phys_{addr,size}_t
where appropriate.
* Typedef'ed page_num_t to phys_addr_t and used it in more places in
vm_page.{h,cpp}.


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


# 23b7090f0945750dc51d90c01cc8d424b98284ce 31-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

is_calling(): Skip non-kernel addresses. Fixes the often not working
"calling" command.


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


# a38f85036021b7ccaffa47fd8584afff473acf3d 22-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* arch_debug_get_stack_trace():
- Replaced the "userOnly" parameter by a "flags" parameter, that allows to
specify kernel and userland stack traces individually.
- x86, m68k: Don't always skip the first frame as that prevents the caller
from being able to record its own address.
* capture_tracing_stack_trace(): Replaced the "userOnly" parameter by
"kernelOnly", since one is probably always interested in the kernel stack
trace, but might not want the userland stack trace.
* Added stack trace support for VM cache kernel tracing.


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


# fe30b74fdef8761c58fb5d0c072c9f61decc7443 06-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix for stack traces in the early boot process: The thread might not have
its stack top/bottom assigned yet.


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


# bbd97b4bb41cc03735528962ff53d89a2a2d7ff2 03-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Made the VMArea fields base and size private and added accessors instead.
This makes it more explicit where the fields are modified.


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


# f34a1dd5d701373687b6f3f0e6e76bd2b1ae6007 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Created VMArea.{h,cpp} and moved VMArea and the global area hash table (new
class VMAreaHash) there.


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


# e50cf8765be50a7454c9488db38b638cf90805af 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


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


# 90d870c1556bdc415c7f41de5474ebebb0ceebdd 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved VMAddressSpace definition to vm_address_space.h.
* "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions
into methods, made all attributes (but "areas") private, and added
accessors.
* Also turned the vm.cpp functions vm_area_lookup() and
remove_area_from_address_space() into VMAddressSpace methods. The rest of
the area management functionality will follow soon.


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


# a99eb6b56f61bd847d246e44885618fdeaa313a1 01-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

vm_area -> VMArea


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


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

* "sc" and "call" will no longer ignore if they couldn't find the thread you
asked them for.


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


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

* Added an arch_debug_stack_trace() function that is called from the KDL loop
in case there aren't any KDL commands available yet.


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


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

Fixed incorrect uses of user_{strl,mem}cpy() in the kernel debugger. This could
break stack traces.


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


# 6a1f462e722992471836c74232c6eb8c8125751b 24-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* arch_debug_get_interrupt_pc() does now optionally return whether the iframe
is a syscall iframe.
* User debugger support: Don't to call BreakpointManager::PrepareToContinue(),
if the thread returns from a syscall. We don't want to skip breakpoints in
that case.


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


# 7927ebb672660db636995b07ed8e257e73be6cce 03-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the appending of '*'/'&' for pointer/reference parameters to the gcc 2
demangler, where it belongs. The gcc 4 stack traces look correct now.


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


# 813d6a742fed83573a923c8fa3707d357b8af4dd 03-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

print_demangled_call(): Use a heap allocated buffer. This allows us to be more
generous with the size.


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


# c33667d400856680a8e0122300861eda77d1847a 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Fixing warnings under GCC4 in preparation to enable -Werror there as well:
* Replaced the use of offsetof() for structs that aren't PODs. Add a
offset_of_member() macro to util/khash.h because that's what it's used for
in our cases.
* Change the signature of add_debugger_command()/remove_debugger_command() on
GCC > 2 to avoid the depricated conversion from string constants to char *.
* Adding some "suggested" parenthesis. I know that not everyone likes that, but
it pointed out at least one bug that is fixed here as well.


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


# 3a5a677501fe251dd0e4ec5b69c1d9976b69f587 31-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* print_demangled_call() now brings some color into your Haiku life (ie. to
the KDL sessions).


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


# 97ba3fb358d7146426acea54d1aade63b61792cb 30-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Instead of faulting when trying to print an invalid string pointer,
print_demangled_call() will now use user_strlcpy() to copy the string
first (if that fails, it will printf '???' to show this).


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


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

* Factored out the demangled function call dump to a print_demangled_call().
* The stack_trace() command now also uses this call by default to give you
the arguments to all functions in a stack crawl (beware of templates for now,
though).
* Use the new option '-d' to disable the demangling. You can now also specify
'-d' in the "call" command which has the same meaning there.
* NULL pointers are now printed as "NULL", and NULL strings are printed as
well.


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


# 715fbb94b479758ca60870d56e7c864edd488747 29-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

arch_debug_get_stack_trace(): We do want the return address of the last
skipped iframe. "profile" didn't capture the top-most function, unless
run with "-s 1".


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


# e670fc6f6346a09cd96a8ef01742e835086bb458 15-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added new parameter "skipIframes" to arch_debug_get_stack_trace(). That
many iframes are supposed to be skipped before recording the stack
trace. Currently implemented for x86 only.


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


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

arch_debug_get_interrupt_pc() does now also support the currently
debugged thread, if set. This makes "dis" without specified address work
when used with "in_context".


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


# 0739b87ee9bca1155746e659d4c24ec902646386 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added arch_debug_get_interrupt_pc(), which is supposed to return the
PC of the innermost iframe.
* The "in_context" command does now set the currently debugged thread
respectively.


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


# 757f253a2d668beb3f02f4a51a4655501fa078f0 22-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added "in_context" debugger command. It takes a thread ID and a command
line and executes the command line in the context of the specified
thread. E.g. "in_context <thread> db <addr>" allows to read memory from
a team that is not active ATM.


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


# 5ccf1db34d70cbd8bda31e7b49ad545b9523468c 04-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Also print whether an iframe is a userland or kernel iframe.
* In case of a kernel iframe the iframe is shorter -- fixed the output
accordingly.


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


# bca3215f8a67e154bbf033a44916b18196d2d546 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced x86_get_double_fault_stack(), which returns the address
and size of the double fault stack.
* is_kernel_stack_address() does now also check whether the given
address is on the double fault stack. This fixes stack traces on
double faults, which were broken (i.e. went only to the double fault
iframe) since we started checking whether the addresses are on the
kernel stack at all.


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


# e146a7bf2f30128750c51ea3217f7cb0e7467e62 06-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Also print the indices of stack frames. This makes the "call" command
more convenient to use.


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


# a8f9741c8c2815234e87b78167738057b976b537 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

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


# ec09e0a89d43d67fcd85d8f4122dadc010ab227b 21-May-2008 Axel Dörfler <axeld@pinc-software.de>

Patch by Jan Klötzke:
* For vm86 mode the kernel stack top is adjusted -> do not rely on the
kernel_stack_base + KERNEL_STACK_SIZE calculation.


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


# 4dd0a2c7b6c006741e8a14fbe8a3a1817e10e1ad 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added arch_debug_get_stack_trace() that can be used to get a stack trace
(the list of return addresses) for the current stack.


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


# ebe5326de334d7f49fb7a03f6607e5d0c795ad60 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


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


# 758962ec3b8fe7a5d9c7463fb5d22c469734b527 26-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added arch_debug_contains_call() function that returns wether or not
a call chain contains a specific symbol (or address).
* Added a new KDL command "calling" that you can use to get a list of
threads that have a specific function in their call chain.
* Removed extraneous white space.


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


# 08f2fdac375616edbdd04a0e66524d516ddf496b 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* "call" now sets some useful debugger variables, like _argX for all arguments,
and _frame for the stack frame.


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


# db18308b906c75432ac60243588db7f288abb797 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed the "call" command to actually show the arguments that belong to the
function name it prints.


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


# fad02fc2ac0537e9f42515bf0067c415afbdb468 28-Jan-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

Print thread ids in decimal.


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


# 2477bce5046dba76204a8c8b75ea773be4ae9748 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for userland symbol lookup in "sc" and "call". Having
used it for an hour or so, I really wonder how we could live without it.
:-)


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


# 1111ffc50b3aa5868d41ada0666bf603c1810fbf 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

An outermost stack frame (having a NULL previous frame) was
incorrectly recognized as iframe. Fixes the read fault when doing "sc"
for a kernel thread.


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


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

* Added support for the "--help" argument to some debugger commands.
* The kernel debugger does now define some temporary variables when
entered (current thread and team, etc.).


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


# 34b3b26b3b8c46ba46ddde037b10dd173f4936d6 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



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


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

* Added a KDL function "call" that can show the arguments together with
a function in the stack trace (only works reliably when a stack frame
is exists, and you'll have to know the number of arguments).
* Refactored the functions a bit and extracted setup_for_thread() out
of stack_trace() to be used by show_call() as well.


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


# e6dc7903e4277bf6e22527ed611df619c7e645f1 26-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* vm.h no longer includes vm_types.h - only those that actually need access
to the private VM types are including vm_types.h now.
* Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's
cleaner this way, and the actual types are only used in C++ files now,
anyway.
* And that caused changes in many files...
* Made commpage.h self-containing.
* Minor cleanup.


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


# 393fceb5a0d8bd8b73059481ca0f20d285ac7a89 27-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up vm_types.h a bit, and made vm_page, vm_cache, and vm_area
opaque types for C.
* As a result, I've renamed some more source files to .cpp, and fixed
all warnings caused by that.


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