diff options
| author | Ingo Weinhold <ingo_weinhold@gmx.de> | 2012-07-23 23:51:05 +0200 |
|---|---|---|
| committer | Ingo Weinhold <ingo_weinhold@gmx.de> | 2012-07-23 23:52:46 +0200 |
| commit | 48b4d20480441b4525de6b90cab9539a834ab8fd (patch) | |
| tree | d043f3caf7676a782a52556a1189ed72511398d6 | |
| parent | 533a73766d9c6c75e93fce67a16fa5c97a5a0b75 (diff) | |
Debugger CLI: Add "threads" commandhrev44391
It just lists the team's thread.
4 files changed, 68 insertions, 1 deletions
diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 2ddf9c8843..f9c017f665 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -176,6 +176,7 @@ Application Debugger : # user_interface/cli CliCommand.cpp CliContext.cpp + CliThreadsCommand.cpp CliQuitCommand.cpp CommandLineUserInterface.cpp diff --git a/src/apps/debugger/user_interface/cli/CliThreadsCommand.cpp b/src/apps/debugger/user_interface/cli/CliThreadsCommand.cpp new file mode 100644 index 0000000000..6bb84f3a87 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliThreadsCommand.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "CliThreadsCommand.h" + +#include <stdio.h> + +#include <AutoLocker.h> + +#include "CliContext.h" +#include "Team.h" +#include "UiUtils.h" + + +CliThreadsCommand::CliThreadsCommand() + : + CliCommand("list the team's threads", + "%s\n" + "Lists the team's threads.") +{ +} + + +void +CliThreadsCommand::Execute(int argc, const char* const* argv, + CliContext& context) +{ + Team* team = context.GetTeam(); + AutoLocker<Team> teamLocker(team); + + printf(" ID state name\n"); + printf("----------------------------\n"); + + for (ThreadList::ConstIterator it = team->Threads().GetIterator(); + Thread* thread = it.Next();) { + const char* stateString = UiUtils::ThreadStateToString( + thread->State(), thread->StoppedReason()); + printf("%10" B_PRId32 " %-9s \"%s\"\n", thread->ID(), stateString, + thread->Name()); + } +} diff --git a/src/apps/debugger/user_interface/cli/CliThreadsCommand.h b/src/apps/debugger/user_interface/cli/CliThreadsCommand.h new file mode 100644 index 0000000000..d22cd44b37 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliThreadsCommand.h @@ -0,0 +1,20 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CLI_THREADS_COMMAND_H +#define CLI_THREADS_COMMAND_H + + +#include "CliCommand.h" + + +class CliThreadsCommand : public CliCommand { +public: + CliThreadsCommand(); + virtual void Execute(int argc, const char* const* argv, + CliContext& context); +}; + + +#endif // CLI_THREADS_COMMAND_H diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 0cb77f6a9e..98103065fe 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -20,6 +20,7 @@ #include "CliContext.h" #include "CliQuitCommand.h" +#include "CliThreadsCommand.h" // #pragma mark - CommandEntry @@ -243,7 +244,8 @@ status_t CommandLineUserInterface::_RegisterCommands() { if (_RegisterCommand("help", new(std::nothrow) HelpCommand(this)) && - _RegisterCommand("quit", new(std::nothrow) CliQuitCommand)) { + _RegisterCommand("quit", new(std::nothrow) CliQuitCommand) && + _RegisterCommand("threads", new(std::nothrow) CliThreadsCommand)) { return B_OK; } |
