diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp index 92a8cece93..46e146dc7f 100644 --- a/src/apps/debugger/Debugger.cpp +++ b/src/apps/debugger/Debugger.cpp @@ -698,7 +698,7 @@ CliDebugger::Run(const Options& options) // create the command line UI CommandLineUserInterface* userInterface = new(std::nothrow) CommandLineUserInterface(options.saveReport, - options.reportPath); + options.reportPath, options.thread); if (userInterface == NULL) { fprintf(stderr, "Error: Out of memory!\n"); return false; diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index f29b87ec0b..48e937a4b8 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012, Rene Gollent, rene@gollent.com. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -13,6 +13,7 @@ #include #include +#include #include #include "CliContext.h" @@ -93,11 +94,12 @@ private: CommandLineUserInterface::CommandLineUserInterface(bool saveReport, - const char* reportPath) + const char* reportPath, thread_id reportTargetThread) : fCommands(20, true), fReportPath(reportPath), fSaveReport(saveReport), + fReportTargetThread(reportTargetThread), fShowSemaphore(-1), fShown(false), fTerminating(false) @@ -219,6 +221,12 @@ CommandLineUserInterface::Run() ArgumentVector args; char buffer[256]; const char* parseErrorLocation; + if (_ReportTargetThreadStopNeeded()) { + snprintf(buffer, sizeof(buffer), "stop %" B_PRId32, + fReportTargetThread); + args.Parse(buffer, &parseErrorLocation); + _ExecuteCommand(args.ArgumentCount(), args.Arguments()); + } snprintf(buffer, sizeof(buffer), "save-report %s", fReportPath != NULL ? fReportPath : ""); args.Parse(buffer, &parseErrorLocation); @@ -443,3 +451,17 @@ CommandLineUserInterface::_CompareCommandEntries(const CommandEntry* command1, } +bool +CommandLineUserInterface::_ReportTargetThreadStopNeeded() const +{ + if (fReportTargetThread < 0) + return false; + + Team* team = fContext.GetTeam(); + AutoLocker teamLocker(team); + Thread* thread = team->ThreadByID(fReportTargetThread); + if (thread == NULL) + return false; + + return thread->State() != THREAD_STATE_STOPPED; +} diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index 2ca34884e3..7f1e534505 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -21,7 +21,8 @@ class CommandLineUserInterface : public UserInterface, public ::Team::Listener { public: CommandLineUserInterface(bool saveReport, - const char* reportPath); + const char* reportPath, + thread_id reportTargetThread); virtual ~CommandLineUserInterface(); virtual const char* ID() const; @@ -76,11 +77,14 @@ private: const CommandEntry* command1, const CommandEntry* command2); + bool _ReportTargetThreadStopNeeded() const; + private: CliContext fContext; CommandList fCommands; const char* fReportPath; bool fSaveReport; + thread_id fReportTargetThread; sem_id fShowSemaphore; bool fShown; volatile bool fTerminating;