Debugger CLI: Add "threads" command
It just lists the team's thread.
This commit is contained in:
@@ -176,6 +176,7 @@ Application Debugger :
|
|||||||
# user_interface/cli
|
# user_interface/cli
|
||||||
CliCommand.cpp
|
CliCommand.cpp
|
||||||
CliContext.cpp
|
CliContext.cpp
|
||||||
|
CliThreadsCommand.cpp
|
||||||
CliQuitCommand.cpp
|
CliQuitCommand.cpp
|
||||||
CommandLineUserInterface.cpp
|
CommandLineUserInterface.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
|
* 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
|
* 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
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "CliContext.h"
|
#include "CliContext.h"
|
||||||
#include "CliQuitCommand.h"
|
#include "CliQuitCommand.h"
|
||||||
|
#include "CliThreadsCommand.h"
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - CommandEntry
|
// #pragma mark - CommandEntry
|
||||||
@@ -243,7 +244,8 @@ status_t
|
|||||||
CommandLineUserInterface::_RegisterCommands()
|
CommandLineUserInterface::_RegisterCommands()
|
||||||
{
|
{
|
||||||
if (_RegisterCommand("help", new(std::nothrow) HelpCommand(this)) &&
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user