From 416458e9c4fbf7332c5431e47541dc319482be99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 12 Jan 2008 23:55:53 +0000 Subject: [PATCH] * 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 --- headers/private/kernel/tracing.h | 25 ++++++++++++++++++++++++- src/system/kernel/debug/tracing.cpp | 11 +++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/headers/private/kernel/tracing.h b/headers/private/kernel/tracing.h index a96f28c9a0..d8eaacb537 100644 --- a/headers/private/kernel/tracing.h +++ b/headers/private/kernel/tracing.h @@ -3,6 +3,7 @@ #include +#include #define ENABLE_TRACING 0 @@ -29,7 +30,29 @@ class TraceEntry : trace_entry { void Initialized(); - void* operator new(size_t size); + void* operator new(size_t size, const std::nothrow_t&) throw(); +}; + +class AbstractTraceEntry : public TraceEntry { + public: + AbstractTraceEntry() + : + fThread(find_thread(NULL)), + fTime(system_time()) + { + } + + virtual void Dump() + { + kprintf("[%6ld] %Ld: ", fThread, fTime); + } + + thread_id Thread() const { return fThread; } + bigtime_t Time() const { return fTime; } + + protected: + thread_id fThread; + bigtime_t fTime; }; #endif // __cplusplus diff --git a/src/system/kernel/debug/tracing.cpp b/src/system/kernel/debug/tracing.cpp index b4e625c85c..4b62035ee8 100644 --- a/src/system/kernel/debug/tracing.cpp +++ b/src/system/kernel/debug/tracing.cpp @@ -101,7 +101,7 @@ TraceEntry::Initialized() void* -TraceEntry::operator new(size_t size) throw() +TraceEntry::operator new(size_t size, const std::nothrow_t&) throw() { #if ENABLE_TRACING if (sBuffer == NULL) @@ -143,17 +143,19 @@ int dump_tracing(int argc, char** argv) { int32 count = 30; + if (argc == 2) + count = strtol(argv[1], NULL, 0); + int32 start = sEntries - count; - if (argc == 2) { - count = strtol(argv[1], NULL, 0); - } else if (argc == 3) { + if (argc == 3) { start = strtol(argv[1], NULL, 0); count = strtol(argv[2], NULL, 0); } else if (argc > 3) { kprintf("usage: %s [start] [count]\n", argv[0]); return 0; } + // TODO: add pattern matching mechanism for the class name if (start < 0) start = 0; @@ -173,6 +175,7 @@ dump_tracing(int argc, char** argv) kprintf("** uninitialized entry **\n"); } + kprintf("%ld of %ld entries.\n", count, sEntries); return 0; }