* 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
This commit is contained in:
@@ -55,13 +55,7 @@ class TraceEntry : public trace_entry {
|
|||||||
|
|
||||||
class AbstractTraceEntry : public TraceEntry {
|
class AbstractTraceEntry : public TraceEntry {
|
||||||
public:
|
public:
|
||||||
AbstractTraceEntry()
|
AbstractTraceEntry();
|
||||||
:
|
|
||||||
fThread(find_thread(NULL)),
|
|
||||||
fTime(system_time())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~AbstractTraceEntry();
|
virtual ~AbstractTraceEntry();
|
||||||
|
|
||||||
virtual void Dump(TraceOutput& out);
|
virtual void Dump(TraceOutput& out);
|
||||||
@@ -69,10 +63,15 @@ class AbstractTraceEntry : public TraceEntry {
|
|||||||
virtual void AddDump(TraceOutput& out);
|
virtual void AddDump(TraceOutput& out);
|
||||||
|
|
||||||
thread_id Thread() const { return fThread; }
|
thread_id Thread() const { return fThread; }
|
||||||
|
thread_id Team() const { return fTeam; }
|
||||||
bigtime_t Time() const { return fTime; }
|
bigtime_t Time() const { return fTime; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
static bool sPrintTeamID;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
|
team_id fTeam;
|
||||||
bigtime_t fTime;
|
bigtime_t fTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
#include <team.h>
|
||||||
|
#include <thread.h>
|
||||||
#include <util/AutoLock.h>
|
#include <util/AutoLock.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -282,6 +284,14 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
AbstractTraceEntry::AbstractTraceEntry()
|
||||||
|
:
|
||||||
|
fThread(thread_get_current_thread_id()),
|
||||||
|
fTeam(team_get_current_team_id()),
|
||||||
|
fTime(system_time())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
AbstractTraceEntry::~AbstractTraceEntry()
|
AbstractTraceEntry::~AbstractTraceEntry()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -290,7 +300,10 @@ AbstractTraceEntry::~AbstractTraceEntry()
|
|||||||
void
|
void
|
||||||
AbstractTraceEntry::Dump(TraceOutput& out)
|
AbstractTraceEntry::Dump(TraceOutput& out)
|
||||||
{
|
{
|
||||||
out.Print("[%6ld] %Ld: ", fThread, fTime);
|
if (sPrintTeamID)
|
||||||
|
out.Print("[%6ld:%6ld] %Ld: ", fThread, fTeam, fTime);
|
||||||
|
else
|
||||||
|
out.Print("[%6ld] %Ld: ", fThread, fTime);
|
||||||
AddDump(out);
|
AddDump(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +314,9 @@ AbstractTraceEntry::AddDump(TraceOutput& out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AbstractTraceEntry::sPrintTeamID = false;
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - trace filters
|
// #pragma mark - trace filters
|
||||||
|
|
||||||
|
|
||||||
@@ -337,6 +353,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
union {
|
union {
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
|
team_id fTeam;
|
||||||
const char* fString;
|
const char* fString;
|
||||||
struct {
|
struct {
|
||||||
TraceFilter* first;
|
TraceFilter* first;
|
||||||
@@ -357,6 +374,17 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TeamTraceFilter : public TraceFilter {
|
||||||
|
public:
|
||||||
|
virtual bool Filter(const TraceEntry* _entry, LazyTraceOutput& out)
|
||||||
|
{
|
||||||
|
const AbstractTraceEntry* entry
|
||||||
|
= dynamic_cast<const AbstractTraceEntry*>(_entry);
|
||||||
|
return (entry != NULL && entry->Team() == fTeam);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class PatternTraceFilter : public TraceFilter {
|
class PatternTraceFilter : public TraceFilter {
|
||||||
public:
|
public:
|
||||||
virtual bool Filter(const TraceEntry* entry, LazyTraceOutput& out)
|
virtual bool Filter(const TraceEntry* entry, LazyTraceOutput& out)
|
||||||
@@ -467,6 +495,17 @@ private:
|
|||||||
ThreadTraceFilter;
|
ThreadTraceFilter;
|
||||||
filter->fThread = strtol(arg, NULL, 0);
|
filter->fThread = strtol(arg, NULL, 0);
|
||||||
return filter;
|
return filter;
|
||||||
|
} else if (strcmp(token, "team") == 0) {
|
||||||
|
const char* arg = _NextToken();
|
||||||
|
if (arg == NULL) {
|
||||||
|
// unexpected end of expression
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceFilter* filter = new(&fFilters[fFilterCount++])
|
||||||
|
TeamTraceFilter;
|
||||||
|
filter->fTeam = strtol(arg, NULL, 0);
|
||||||
|
return filter;
|
||||||
} else {
|
} else {
|
||||||
// invalid token
|
// invalid token
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -648,6 +687,14 @@ dump_tracing(int argc, char** argv)
|
|||||||
|
|
||||||
bool hasFilter = false;
|
bool hasFilter = false;
|
||||||
|
|
||||||
|
AbstractTraceEntry::sPrintTeamID = false;
|
||||||
|
if (argi < argc) {
|
||||||
|
if (strcmp(argv[argi], "printteam") == 0) {
|
||||||
|
AbstractTraceEntry::sPrintTeamID = true;
|
||||||
|
argi++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (argi < argc) {
|
if (argi < argc) {
|
||||||
if (strcmp(argv[argi], "forward") == 0) {
|
if (strcmp(argv[argi], "forward") == 0) {
|
||||||
cont = 1;
|
cont = 1;
|
||||||
@@ -936,13 +983,15 @@ tracing_init(void)
|
|||||||
|
|
||||||
add_debugger_command_etc("traced", &dump_tracing,
|
add_debugger_command_etc("traced", &dump_tracing,
|
||||||
"Dump recorded trace entries",
|
"Dump recorded trace entries",
|
||||||
"(\"forward\" | \"backward\") | ([ <start> [ <count> [ <range> ] ] ] "
|
"[ \"printteam\" ] (\"forward\" | \"backward\") "
|
||||||
"[ #<pattern> | (\"filter\" <filter>) ])\n"
|
"| ([ <start> [ <count> [ <range> ] ] ] "
|
||||||
|
"[ #<pattern> | (\"filter\" <filter>) ])\n"
|
||||||
"Prints recorded trace entries. If \"backward\" or \"forward\" is\n"
|
"Prints recorded trace entries. If \"backward\" or \"forward\" is\n"
|
||||||
"specified, the command continues where the previous invocation left\n"
|
"specified, the command continues where the previous invocation left\n"
|
||||||
"off, i.e. printing the previous respectively next entries (as many\n"
|
"off, i.e. printing the previous respectively next entries (as many\n"
|
||||||
"as printed before). In this case the command is continuable, that is\n"
|
"as printed before). In this case the command is continuable, that is\n"
|
||||||
"afterwards entering an empty line in the debugger will reinvoke it.\n"
|
"afterwards entering an empty line in the debugger will reinvoke it.\n"
|
||||||
|
"\"printteam\" enables printing the items' team ID.\n"
|
||||||
" <start> - The base index of the entries to print. Depending on\n"
|
" <start> - The base index of the entries to print. Depending on\n"
|
||||||
" whether the iteration direction is forward or\n"
|
" whether the iteration direction is forward or\n"
|
||||||
" backward this will be the first or last entry printed\n"
|
" backward this will be the first or last entry printed\n"
|
||||||
@@ -967,11 +1016,12 @@ tracing_init(void)
|
|||||||
" printed.\n"
|
" printed.\n"
|
||||||
" <filter> - If specified only entries matching this filter\n"
|
" <filter> - If specified only entries matching this filter\n"
|
||||||
" expression are printed. The expression can consist of\n"
|
" expression are printed. The expression can consist of\n"
|
||||||
" prefix operators \"not\", \"and\", \"or\", filters of\n"
|
" prefix operators \"not\", \"and\", \"or\", and\n"
|
||||||
" the kind \"'thread' <thread>\" (matching entries\n"
|
" filters \"'thread' <thread>\" (matching entries\n"
|
||||||
" with the given thread ID), or filter of the kind\n"
|
" with the given thread ID), \"'team' <team>\"\n"
|
||||||
|
"(matching entries with the given team ID), and\n"
|
||||||
" \"#<pattern>\" (matching entries containing the given\n"
|
" \"#<pattern>\" (matching entries containing the given\n"
|
||||||
" string.\n", 0);
|
" string).\n", 0);
|
||||||
#endif // ENABLE_TRACING
|
#endif // ENABLE_TRACING
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user