History log of /haiku/src/system/kernel/debug/tracing.cpp
Revision Date Author Comments
# 40ee778c 12-Feb-2019 Rob Gill <rrobgill@protonmail.com>

Fix memory leaks

* Delete/free as appropriate

Most cases involve not freeing memory after encountering error or
unexpected situation (identified via cppcheck static analysis)

Change-Id: I90ba2fca518b00d2dfa9ec1ddbcebe1920a34b7c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1038
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3c70914f 07-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ktracing: TraceOutput::PrintStackTrace(): Fix duplication


# c53508b7 11-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

kernel tracing: implement fallback for meta data allocation

We the meta data area couldn't be allocated in any of the supported
(reattachable) places, just use a static allocation. The tracing feature
wouldn't be available at all in such a case.


# 8627383b 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation errors with ENABLE_TRACING set.


# d1f280c8 01-Apr-2012 Hamish Morrison <hamishm53@gmail.com>

Add support for pthread_attr_get/setguardsize()

* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
only.


# 1e068aea 19-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Slight improvement to tracing output.

- If a trace entry has a stack trace, attempt to demangle the associated symbols.
Could be enhanced further to also demangle the arguments but doesn't yet.
Interestingly there are some mangled symbols that our demangler appears to
not handle correctly (gcc4).


# 4f78437c 02-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Style fix.


# 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.


# 9a79e531 02-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Introduce TracingMetaData::IsInBuffer() to validate that a certain memory
range is within the valid tracing buffer limits.
* Use that when validating in tracing_is_entry_valid() before trying to access
the entry, resolving a TODO.
* Validate the candidate time against the handed in time (if specified) as an
additional check.
* Tiny unrelated text cleanup.


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


# 45cbd814 01-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

Fix build with tracing disabled. Since capture_tracing_stack_trace() doesn't
return a stack trace when tracing is disabled we don't really need to be able
to print one either.


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


# 328df922 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Add TraceOutput::PrintArgs(), a va_list version of Print().
* Move code of TraceOutput::Print() to new private template function
print_stack_trace().
* Add public tracing_print_stack_trace().


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


# 69d7ad7d 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Move struct tracing_stack_trace to tracing.h header.
* Add tracing_find_caller_in_stack_trace(). Helper function to get the
first return address of a stack trace that is not in one of the given
address ranges.
* Add AbstractTracingEntryWithStackTrace::StackTrace() getter.
* Add tracing_is_entry_valid(). Checks, based on the additionally given
time, whether a tracing entry is (probably) still in the tracing
buffer.


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


# fe8f0f46 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add an AbstractTraceEntryWithStackTrace that includes stack trace handling.
* Add a selector macro/template combo to conveniently select the right base
class depending on whether stack traces are enabled or not.
* Minor style cleanups.


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


# b0eaa06c 02-Jul-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Disable re-attaching the tracing buffer of a previous session. It still has
some problems.


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


# cdb638a8 17-Jun-2010 Axel Dörfler <axeld@pinc-software.de>

* Seems like someone wasn't quite awake when doing these changes; the kernel
now compiles again with tracing turned on.


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


# a8ad734f 14-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced structures {virtual,physical}_address_restrictions, which specify
restrictions for virtual/physical addresses.
* vm_page_allocate_page_run():
- Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not
taken into account.
- Takes a physical_address_restrictions instead of base/limit and also
supports alignment and boundary restrictions, now.
* map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/
ReserveAddressRange() take a virtual_address_restrictions parameter, now. They
also support an alignment independent from the range size.
* create_area_etc(), vm_create_anonymous_area(): Take
{virtual,physical}_address_restrictions parameters, now.
* Removed no longer needed B_PHYSICAL_BASE_ADDRESS.
* DMAResources:
- Fixed potential overflows of uint32 when initializing from device node
attributes.
- Fixed bounce buffer creation TODOs: By using create_area_etc() with the
new restrictions parameters we can directly support physical high address,
boundary, and alignment.


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


# 64d79eff 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


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


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

* During early kernel startup, we must not create areas without the
CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed.
* I hope I found all occurences, but there might be some areas left (note,
only those that don't use B_ALREADY_WIRED are problematic).


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


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

* Fixed typo.


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


# 1aed2639 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

TracingMetaData::_InitPreviousTracingData():
* More output.
* Actually increment errorCount when encountering an error. The loop
condition would never be false this way.


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


# 4502d80d 31-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

capture_tracing_stack_trace():
* When interrupts are disabled, it is still safe to capture the kernel stack
trace. The respective TODO preceded the introduction of the "kernelOnly"
flag.
* Actually made "kernelOnly" work. The wrong flag was passed to
arch_debug_get_stack_trace() in case it was false, so we never captured
user stack traces.


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


# 3ce26345 30-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would
be written, if the buffer were large enough.
Added a touch of C++ while doing that. :-)
* Fixed the instances in boot loader, kernel, and kernel modules where the
wrong semantics were expected. The majority of uses actually.


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


# 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


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

Don't destroy tracing entries. This is not necessary and even harmful, if the
code is no longer loaded, e.g. when the module has been unloaded or the tracing
buffer was reattached from a previous session.


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


# ce50cdc3 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

When recovering a tracing buffer from a previous session we do now check the
tracing buffer entry list at least. Eventually we should check the entries
themselves, too.


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


# 3fccf067 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

C++ified the code. Introduced new trace entry flags, which will eventually be
used to mark entries after recovering a tracing log from a previous session.


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


# 57a25014 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Statically initialize sTracingMetaData to sDummyTracingMetaData. This causes
tracing use before real initialization to be ignored gracefully again. Fixes
#4158.


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


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

mmlr + bonefish:
Moved the static variables for managing the tracing buffer into a separate
area. The area is mapped at one of a few possible physical addresses and can
be found again when rebooting. This allows us to resurrect the tracing buffer
from the previous session, which could help tremendously when tracking certain
bugs (like triple faults). There's very little checking done yet, so it is
probably not as robust as we would wish it to be.


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


# 00e8c084 10-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

Extremely important cleanup.


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


# 093e0057 07-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Added --stacktrace to the flat list of options.
* Removed superfluous and uncommon '"' around options.


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


# bc6a5f86 15-Oct-2008 Oliver Tappe <zooey@hirschkaefer.de>

bonefish + zooey:
* added tracing of stack traces to userspace entries


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


# aa1a64f3 03-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added [un]lock_tracing_buffer(). This allows other components to analyze
tracing buffer entries even when not in the kernel debugger.


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


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

* Made TraceEntryIterator available in the kernel.
* Fixed TraceEntryIterator::Current(): If fEntry was NULL, it would
return 0x4.


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


# b3d6c12d 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed kernel tracing for gcc 4. The ABI changed in a way that isn't
compatible with what our code assumed (pointers to objects of
TraceEntry and its POD base class trace_entry aren't identical
anymore).
* Added optional stack traces for ktrace_printf() output in the kernel.


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


# b2d95c3c 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reverted r25209. We need the symbol even with tracing disabled, since
modules could use it. Moved the tracing_stack_trace definition out of
the conditional section instead.
* Made the TraceOutput::Print()/PrintStackTrace() method no-ops when
tracing is disabled.


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


# fe2edb70 27-Apr-2008 Rene Gollent <anevilyak@gmail.com>

This function needs to be conditional on ENABLE_TRACING also, otherwise the build breaks.



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


# 65f40152 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Support for stack traces in tracing entries:
* Added capture_tracing_stack_trace() which allocates space in the
tracing buffer and captures the stack trace according to the given
parameters.
* Added TraceOutput::PrintStackTrace() to print a stack trace thus
created.
* Added TraceEntry::DumpStackTrace() callback which is supposed to print
a stack trace for the entry, if it can do that.
* Added "--stacktrace" switch to the "traced" command, which causes the
stack traces for all entries that have one to be printed as well.


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


# f97199ed 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made dump_tracing() (the "traced" command function) available in the
kernel and added a WrapperTraceFilter* parameter, which allows for
additional filtering. This way other commands can print tracing output
with special filtering.


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


# 0c45a120 19-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Ignore the trailing new line when printing trace entries.


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


# 989a6e05 27-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made kernel tracing safe to be used right after it has officially
been initialized.


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


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

* Added new pattern filters d#<expr>, x#<expr>, and s#<expr> which
set the actual pattern as "%d", "%x", and "%s" of the expression
after '#' respectively. They are very slow, though.


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


# 7d2d758d 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Make ktrace_printf() available in the kernel, too.


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


# 350b6dbc 04-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed AbstractTraceEntry::sPrintTeamID and added a flags field to
TraceOutput for output options instead.
* Added "traced" option --difftime. Instead of the absolute system time
it prints the difference time to the previously printed entry.


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


# a02bbcd4 31-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed "printteam" switch for "traced" command to "--printteam".


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


# 5fa74667 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed semantics of "traced" invocation without arguments. Instead of
printing the last 30 entries, it continues the last iteration, thus
making the more common use case more comfortable. The old functionality
is still available via "traced 0".


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


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

Added experimental ktrace_[v]printf() functions to libroot. Their output
is recorded in a kernel trace entry (if tracing is enabled).


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


# 64fe37ee 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* AbstractTraceEntry records the team ID too, now.
* Added "printteam" switch to "traced" command, enabling the printing of
the team ID.
* Added "team" filter to the "traced" command expression language.


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


# 56213ff4 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Some "traced" command optimizations:
* Made the iterator static, so that it's possible to move from the
iteration position of the previous invocation to the current start,
instead of always having to start from the beginning or the end.
* Filtered backward iteration:
- Restrict the range to dump to the entries between the first and the
last filter match.
- Use new FILTER_MATCH entry flag to avoid applying the filter a
second time in the print loop.


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


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

* Fixed my fix for make_space() wrapping. It's always a good idea to
write code aligned to what one has written in the comment (or the
other way around).
* Made trace_entry structure doubly linked, by introducing a
previous_size member. By using bit fields, shrinking the flags field
to 4 bits, and not saving the lower two bits of size and previous_size
(which are always 0 due to alignment), the structure remains 4 byte
sized and can still address the same entry size.
* kBufferSize is no longer one less than it could be.
* "traced" command:
- Use static variable for the iteration state rather then cluttering
the temporary debug variable name space.
- The <count> parameter can now be negative, in which case the entries
before (and including) <start> are printed.
- Added a new optional parameter, specifying the maximal number of
entries to be filtered. Filtered iteration is beautifully
comfortable now.


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


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

* Use dprintf_no_syslog() for debug output, since we have interrupts
disabled in most cases.
* Wrapping in make_space() was broken. When wrapping the second time or
later, sFirstEntry would already be greater than sAfterLastEntry and
resetting sAfterLastEntry to the beginning of the buffer would
erroneously "free" all entries between the buffer start and the
original sAfterLastEntry. If the tracing buffer was small enough,
the odds were that a not yet fully initialized entry would already
be re-allocated, causing all kinds of weird behavior.
* When an entry that is not yet fully initialized needs to be
freed, we let the allocation causing the freeing fail. We can't wait
for the entry, since we've interrupts disabled and since the entry
initialization might even try to allocate more (buffer) entries.
* make_space() is now safe to be called in any situation, and
allocate_entry() will do that, which simplifies things there and
avoids a few duplicate checks.
* Moved maximum allocation size check from alloc_tracing_buffer() to
allocate_entry(). Just in case... :-)


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


# 4c4b14c3 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The "traced" command can now be passed a filter expression consisting of
boolean operators ("not", "and", "or") and filters matching thread IDs
or contained strings.
I'm still not fully happy with the command. It should be possible to
define a filter and then comfortably scroll through the matching
entries. Currently having to specify an index range of the unfiltered
entries is rather unhandy in combination with filtering.


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


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

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


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


# f1047a1c 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduced helper class TraceOutput that represents an output buffer
and added AbstractTraceEntry::AddDump(TraceOutput&) method.


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


# 8bd6d45d 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* If passed a userland pointer alloc_tracing_buffer_{memcpy,strcpy}()
checks it now.
* Check for NULL pointer in alloc_tracing_buffer_strcpy(), and also
determine the length of userland strings before allocating the buffer
(using user_strlcpy()).


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


# 960f8f24 18-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed sBufferStart to sFirstEntry, and sBufferEnd to
sAfterLastEntry.


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


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

* alloc_tracing_buffer() now refuses to allocate more than 65532 bytes;
we use a uint16 size internally (and that has to include the length of
the trace_entry structure, too.
* We now track how many entries have been written to the log during the
runtime.


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


# a7e979ca 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Print the correct usage when too many parameters were given.


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


# 74652349 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* sEntries only counts the "normal" (i.e. non-buffer) entries, now.
* "traced" command:
- Was printing one more entry than asked to.
- Fixed broken index handling. They were starting at 0, but the last
one was sEntries nevertheless. We consistently let them start at 1,
now. 0 can be passed as special index, causing the last entries to
be printed.
- Added options "backward"/"forward" which will print the entries
preceding respectively succeeding the ones printed on the previous
invocation. The command is continuable in this case, i.e. simply
pressing RET afterwards will reinvoke the command, allowing for
comfortable scrolling through a long list of entries.
- Added detailed usage message.


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


# 21c92a08 17-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Don't invoke the TraceEntry destructor for simple buffer entries,
since that's seriously unhealthy.
* Added TODO that uninitialized entries must not be discarded.


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


# 0b60583f 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added convenience functions alloc_tracing_buffer_{memcpy,strcpy}().


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


# 36a3ef57 15-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* "traced" now always prints the index numbers (before, it only did that
when a pattern was involved).
* alloc_tracing_buffer() no longer allocates anything when you ask for
a zero byte buffer.
* Fixed warning.


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


# 2d81f045 14-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* If the "traced" KDL command is used with only one argument, it's the index
now, not the number of entries shown (much more usable this way).
* Added missing license.


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


# 5276dad0 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug in make_space() that would endlessly skip entries, even
though there was nothing to do (if 'diff' was larger than 'needed').
* Improved KDL command output.
* Added debug output to the allocation functions.
* Minor cleanup.


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


# 8e43ece8 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


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


# 416458e9 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added nothrow to the new operator because otherwise the C++ compiler
will not accept if the allocator returns NULL and crashes instead
(ie. not compiling in tracing would have crashed if some module tried
to use it).
* Added total entries count to the KDL command output.
* Fixed computing the start index of the KDL command.


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


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

bonefish+axeld:
* Implemented an optional tracing layer that can be used in the kernel.
Nice to use if you don't have serial output or need something that doesn't
slow down the system as much.


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


# 3c70914f66b16a35d5aad91c934bb03a5178568f 07-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ktracing: TraceOutput::PrintStackTrace(): Fix duplication


# c53508b7305c6b91c250a39fd90bf16ea949484a 11-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

kernel tracing: implement fallback for meta data allocation

We the meta data area couldn't be allocated in any of the supported
(reattachable) places, just use a static allocation. The tracing feature
wouldn't be available at all in such a case.


# 8627383bf7cc58f79f41a926331aa113814401d4 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation errors with ENABLE_TRACING set.


# d1f280c80529d5f0bc55030c2934f9255bc7f6a2 01-Apr-2012 Hamish Morrison <hamishm53@gmail.com>

Add support for pthread_attr_get/setguardsize()

* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
only.


# 1e068aea46aede60db6c8fe4410fd6d2633ce2da 19-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Slight improvement to tracing output.

- If a trace entry has a stack trace, attempt to demangle the associated symbols.
Could be enhanced further to also demangle the arguments but doesn't yet.
Interestingly there are some mangled symbols that our demangler appears to
not handle correctly (gcc4).


# 4f78437c0d5ba6c2904dd0b1f658f9711d397815 02-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Style fix.


# 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.


# 9a79e531ef6443998486e0dcac51f5ecdf029448 02-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Introduce TracingMetaData::IsInBuffer() to validate that a certain memory
range is within the valid tracing buffer limits.
* Use that when validating in tracing_is_entry_valid() before trying to access
the entry, resolving a TODO.
* Validate the candidate time against the handed in time (if specified) as an
additional check.
* Tiny unrelated text cleanup.


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


# 45cbd8143649b2fc1a82b9d153eaf52073f641dd 01-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

Fix build with tracing disabled. Since capture_tracing_stack_trace() doesn't
return a stack trace when tracing is disabled we don't really need to be able
to print one either.


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


# 328df922e6fe47e466937aa518456b10ec7a9320 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Add TraceOutput::PrintArgs(), a va_list version of Print().
* Move code of TraceOutput::Print() to new private template function
print_stack_trace().
* Add public tracing_print_stack_trace().


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


# 69d7ad7dc5b8d1281aa8f19e2d0347b3721b96a6 01-Nov-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmlr + bonefish:
* Move struct tracing_stack_trace to tracing.h header.
* Add tracing_find_caller_in_stack_trace(). Helper function to get the
first return address of a stack trace that is not in one of the given
address ranges.
* Add AbstractTracingEntryWithStackTrace::StackTrace() getter.
* Add tracing_is_entry_valid(). Checks, based on the additionally given
time, whether a tracing entry is (probably) still in the tracing
buffer.


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


# fe8f0f4601874527071ef066e8550e07323f9f51 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add an AbstractTraceEntryWithStackTrace that includes stack trace handling.
* Add a selector macro/template combo to conveniently select the right base
class depending on whether stack traces are enabled or not.
* Minor style cleanups.


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


# b0eaa06c2673fb040394746fdcad4312f0496a60 02-Jul-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Disable re-attaching the tracing buffer of a previous session. It still has
some problems.


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


# cdb638a8ee25acb67a8feeec221454f7d2dea8c9 17-Jun-2010 Axel Dörfler <axeld@pinc-software.de>

* Seems like someone wasn't quite awake when doing these changes; the kernel
now compiles again with tracing turned on.


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


# a8ad734f1c698917badb15e1641e0f38b3e9a013 14-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced structures {virtual,physical}_address_restrictions, which specify
restrictions for virtual/physical addresses.
* vm_page_allocate_page_run():
- Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not
taken into account.
- Takes a physical_address_restrictions instead of base/limit and also
supports alignment and boundary restrictions, now.
* map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/
ReserveAddressRange() take a virtual_address_restrictions parameter, now. They
also support an alignment independent from the range size.
* create_area_etc(), vm_create_anonymous_area(): Take
{virtual,physical}_address_restrictions parameters, now.
* Removed no longer needed B_PHYSICAL_BASE_ADDRESS.
* DMAResources:
- Fixed potential overflows of uint32 when initializing from device node
attributes.
- Fixed bounce buffer creation TODOs: By using create_area_etc() with the
new restrictions parameters we can directly support physical high address,
boundary, and alignment.


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


# 64d79eff7290437d24b1a420537c3ed5c144ab96 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed physical_entry::{address,size} to phys_{addr,size}_t and changed
map_physical_memory()'s physicalAddress parameter type from void* to
phys_addr_t. This breaks source compatibility, but -- as long as
phys_{addr,size}_t remain 32 bit wide -- keeps binary compatibility with
BeOS.
* Adjusted all code using the affected interfaces (Oh what fun!). Added a few
TODOs in places where the wrong types (e.g. void* for physical addresses
are used). Looks like quite a few drivers aren't 64 bit safe and others
will break with PAE.


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


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

* During early kernel startup, we must not create areas without the
CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed.
* I hope I found all occurences, but there might be some areas left (note,
only those that don't use B_ALREADY_WIRED are problematic).


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


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

* Fixed typo.


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


# 1aed2639980676c51f2a3e102ea3cc2e745adb65 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

TracingMetaData::_InitPreviousTracingData():
* More output.
* Actually increment errorCount when encountering an error. The loop
condition would never be false this way.


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


# 4502d80d7e46775573ccdee7f74da9af70ec2ba8 31-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

capture_tracing_stack_trace():
* When interrupts are disabled, it is still safe to capture the kernel stack
trace. The respective TODO preceded the introduction of the "kernelOnly"
flag.
* Actually made "kernelOnly" work. The wrong flag was passed to
arch_debug_get_stack_trace() in case it was false, so we never captured
user stack traces.


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


# 3ce26345338e484601eb0a6598414d22cb73c9cc 30-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would
be written, if the buffer were large enough.
Added a touch of C++ while doing that. :-)
* Fixed the instances in boot loader, kernel, and kernel modules where the
wrong semantics were expected. The majority of uses actually.


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


# 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


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

Don't destroy tracing entries. This is not necessary and even harmful, if the
code is no longer loaded, e.g. when the module has been unloaded or the tracing
buffer was reattached from a previous session.


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


# ce50cdc3ed83718751a1d7388c5780a10cdf160a 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

When recovering a tracing buffer from a previous session we do now check the
tracing buffer entry list at least. Eventually we should check the entries
themselves, too.


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


# 3fccf0679fae4ee6bab9952525be0c0e4bc58873 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

C++ified the code. Introduced new trace entry flags, which will eventually be
used to mark entries after recovering a tracing log from a previous session.


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


# 57a25014b0ab40d1cf73b0188701e2069e4b12fe 30-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Statically initialize sTracingMetaData to sDummyTracingMetaData. This causes
tracing use before real initialization to be ignored gracefully again. Fixes
#4158.


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


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

mmlr + bonefish:
Moved the static variables for managing the tracing buffer into a separate
area. The area is mapped at one of a few possible physical addresses and can
be found again when rebooting. This allows us to resurrect the tracing buffer
from the previous session, which could help tremendously when tracking certain
bugs (like triple faults). There's very little checking done yet, so it is
probably not as robust as we would wish it to be.


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


# 00e8c084e611e9916ddba10c64c68fa7401456fe 10-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

Extremely important cleanup.


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


# 093e00573f01a753b1c94f8d8bc5ba2e2289464d 07-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Added --stacktrace to the flat list of options.
* Removed superfluous and uncommon '"' around options.


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


# bc6a5f8697f8b8b2d245bfa871ae67c8a6c47413 15-Oct-2008 Oliver Tappe <zooey@hirschkaefer.de>

bonefish + zooey:
* added tracing of stack traces to userspace entries


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


# aa1a64f35ac101f1b9ea6d1f5f0211d8e187e7b7 03-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added [un]lock_tracing_buffer(). This allows other components to analyze
tracing buffer entries even when not in the kernel debugger.


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


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

* Made TraceEntryIterator available in the kernel.
* Fixed TraceEntryIterator::Current(): If fEntry was NULL, it would
return 0x4.


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


# b3d6c12dbf620c22c071b1a6a4c44dfce88d265c 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed kernel tracing for gcc 4. The ABI changed in a way that isn't
compatible with what our code assumed (pointers to objects of
TraceEntry and its POD base class trace_entry aren't identical
anymore).
* Added optional stack traces for ktrace_printf() output in the kernel.


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


# b2d95c3c1dc89dd28b0132d2ac9355c1f3ebbf6b 27-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reverted r25209. We need the symbol even with tracing disabled, since
modules could use it. Moved the tracing_stack_trace definition out of
the conditional section instead.
* Made the TraceOutput::Print()/PrintStackTrace() method no-ops when
tracing is disabled.


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


# fe2edb706d28697ecb43009bb428033010ab30aa 27-Apr-2008 Rene Gollent <anevilyak@gmail.com>

This function needs to be conditional on ENABLE_TRACING also, otherwise the build breaks.



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


# 65f4015279776018f638227d9fd71fc062c2359c 26-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Support for stack traces in tracing entries:
* Added capture_tracing_stack_trace() which allocates space in the
tracing buffer and captures the stack trace according to the given
parameters.
* Added TraceOutput::PrintStackTrace() to print a stack trace thus
created.
* Added TraceEntry::DumpStackTrace() callback which is supposed to print
a stack trace for the entry, if it can do that.
* Added "--stacktrace" switch to the "traced" command, which causes the
stack traces for all entries that have one to be printed as well.


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


# f97199edd3ead2cd14ce2a844fab290076a2ad54 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made dump_tracing() (the "traced" command function) available in the
kernel and added a WrapperTraceFilter* parameter, which allows for
additional filtering. This way other commands can print tracing output
with special filtering.


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


# 0c45a1202d10b1a3f0c682b47d3a68767e521aac 19-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Ignore the trailing new line when printing trace entries.


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


# 989a6e05ec97b2f8dc26505e4d768e7eb5430b7e 27-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Made kernel tracing safe to be used right after it has officially
been initialized.


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


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

* Added new pattern filters d#<expr>, x#<expr>, and s#<expr> which
set the actual pattern as "%d", "%x", and "%s" of the expression
after '#' respectively. They are very slow, though.


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


# 7d2d758d46d0047fa4e410e62f0a4f1eeb7d3a76 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Make ktrace_printf() available in the kernel, too.


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


# 350b6dbc3aa9b7387f8003fe5f9957e84742eec3 04-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed AbstractTraceEntry::sPrintTeamID and added a flags field to
TraceOutput for output options instead.
* Added "traced" option --difftime. Instead of the absolute system time
it prints the difference time to the previously printed entry.


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


# a02bbcd455fd14670f27ca0aa5a66503db171d63 31-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed "printteam" switch for "traced" command to "--printteam".


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


# 5fa74667c5bdb8262d3b13cb4e07c71a95cc0db0 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed semantics of "traced" invocation without arguments. Instead of
printing the last 30 entries, it continues the last iteration, thus
making the more common use case more comfortable. The old functionality
is still available via "traced 0".


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


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

Added experimental ktrace_[v]printf() functions to libroot. Their output
is recorded in a kernel trace entry (if tracing is enabled).


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


# 64fe37ee897678e76e9b6a9b03b831bfeaeddc71 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* AbstractTraceEntry records the team ID too, now.
* Added "printteam" switch to "traced" command, enabling the printing of
the team ID.
* Added "team" filter to the "traced" command expression language.


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


# 56213ff41aa7a48b2e529d901a025ef47a7b3f79 21-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Some "traced" command optimizations:
* Made the iterator static, so that it's possible to move from the
iteration position of the previous invocation to the current start,
instead of always having to start from the beginning or the end.
* Filtered backward iteration:
- Restrict the range to dump to the entries between the first and the
last filter match.
- Use new FILTER_MATCH entry flag to avoid applying the filter a
second time in the print loop.


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


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

* Fixed my fix for make_space() wrapping. It's always a good idea to
write code aligned to what one has written in the comment (or the
other way around).
* Made trace_entry structure doubly linked, by introducing a
previous_size member. By using bit fields, shrinking the flags field
to 4 bits, and not saving the lower two bits of size and previous_size
(which are always 0 due to alignment), the structure remains 4 byte
sized and can still address the same entry size.
* kBufferSize is no longer one less than it could be.
* "traced" command:
- Use static variable for the iteration state rather then cluttering
the temporary debug variable name space.
- The <count> parameter can now be negative, in which case the entries
before (and including) <start> are printed.
- Added a new optional parameter, specifying the maximal number of
entries to be filtered. Filtered iteration is beautifully
comfortable now.


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


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

* Use dprintf_no_syslog() for debug output, since we have interrupts
disabled in most cases.
* Wrapping in make_space() was broken. When wrapping the second time or
later, sFirstEntry would already be greater than sAfterLastEntry and
resetting sAfterLastEntry to the beginning of the buffer would
erroneously "free" all entries between the buffer start and the
original sAfterLastEntry. If the tracing buffer was small enough,
the odds were that a not yet fully initialized entry would already
be re-allocated, causing all kinds of weird behavior.
* When an entry that is not yet fully initialized needs to be
freed, we let the allocation causing the freeing fail. We can't wait
for the entry, since we've interrupts disabled and since the entry
initialization might even try to allocate more (buffer) entries.
* make_space() is now safe to be called in any situation, and
allocate_entry() will do that, which simplifies things there and
avoids a few duplicate checks.
* Moved maximum allocation size check from alloc_tracing_buffer() to
allocate_entry(). Just in case... :-)


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


# 4c4b14c3bbb2cc9f073ae3d209539d8229a6664f 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The "traced" command can now be passed a filter expression consisting of
boolean operators ("not", "and", "or") and filters matching thread IDs
or contained strings.
I'm still not fully happy with the command. It should be possible to
define a filter and then comfortably scroll through the matching
entries. Currently having to specify an index range of the unfiltered
entries is rather unhandy in combination with filtering.


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


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

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


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


# f1047a1c3e3278a357db2fc7f0241731e090ca2b 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduced helper class TraceOutput that represents an output buffer
and added AbstractTraceEntry::AddDump(TraceOutput&) method.


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


# 8bd6d45df3777dfbeb13495d23406a2c04e19243 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* If passed a userland pointer alloc_tracing_buffer_{memcpy,strcpy}()
checks it now.
* Check for NULL pointer in alloc_tracing_buffer_strcpy(), and also
determine the length of userland strings before allocating the buffer
(using user_strlcpy()).


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


# 960f8f24309425ac3ed98708eaebdff11a7a97fb 18-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed sBufferStart to sFirstEntry, and sBufferEnd to
sAfterLastEntry.


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


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

* alloc_tracing_buffer() now refuses to allocate more than 65532 bytes;
we use a uint16 size internally (and that has to include the length of
the trace_entry structure, too.
* We now track how many entries have been written to the log during the
runtime.


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


# a7e979cabbc006c98b711dc47a047e06cb38e071 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Print the correct usage when too many parameters were given.


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


# 74652349dd822b38b1059aabd76930fed8774bd5 18-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* sEntries only counts the "normal" (i.e. non-buffer) entries, now.
* "traced" command:
- Was printing one more entry than asked to.
- Fixed broken index handling. They were starting at 0, but the last
one was sEntries nevertheless. We consistently let them start at 1,
now. 0 can be passed as special index, causing the last entries to
be printed.
- Added options "backward"/"forward" which will print the entries
preceding respectively succeeding the ones printed on the previous
invocation. The command is continuable in this case, i.e. simply
pressing RET afterwards will reinvoke the command, allowing for
comfortable scrolling through a long list of entries.
- Added detailed usage message.


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


# 21c92a08d46268e191424b768584fb30527c219a 17-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Don't invoke the TraceEntry destructor for simple buffer entries,
since that's seriously unhealthy.
* Added TODO that uninitialized entries must not be discarded.


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


# 0b60583fec75f23e86b98057dc08c2c425561a8d 16-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added convenience functions alloc_tracing_buffer_{memcpy,strcpy}().


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


# 36a3ef573d364afa5096aac41aaf321e98df902c 15-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* "traced" now always prints the index numbers (before, it only did that
when a pattern was involved).
* alloc_tracing_buffer() no longer allocates anything when you ask for
a zero byte buffer.
* Fixed warning.


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


# 2d81f04529d752e536c7a44d9a7c8b06371ac7e7 14-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* If the "traced" KDL command is used with only one argument, it's the index
now, not the number of entries shown (much more usable this way).
* Added missing license.


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


# 5276dad05770ff3d0dcfbd56c5fac9fa2b45bae9 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug in make_space() that would endlessly skip entries, even
though there was nothing to do (if 'diff' was larger than 'needed').
* Improved KDL command output.
* Added debug output to the allocation functions.
* Minor cleanup.


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


# 8e43ece8b85e5842fad76f130eae4dfd7e5eacd7 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


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


# 416458e9c4fbf7332c5431e47541dc319482be99 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added nothrow to the new operator because otherwise the C++ compiler
will not accept if the allocator returns NULL and crashes instead
(ie. not compiling in tracing would have crashed if some module tried
to use it).
* Added total entries count to the KDL command output.
* Fixed computing the start index of the KDL command.


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


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

bonefish+axeld:
* Implemented an optional tracing layer that can be used in the kernel.
Nice to use if you don't have serial output or need something that doesn't
slow down the system as much.


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