Debugger: Implement #10283.
- When constructing the CLI interface, also pass along the target thread ID if one was specified. - If our only reason for starting is to save a report, and we've been given a specific thread to target, rather than just a team, ensure that the target thread is in a stopped state prior to saving the report.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2012, Rene Gollent, [email protected].
|
||||
* Copyright 2011-2013, Rene Gollent, [email protected].
|
||||
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <ArgumentVector.h>
|
||||
#include <AutoDeleter.h>
|
||||
#include <AutoLocker.h>
|
||||
#include <Referenceable.h>
|
||||
|
||||
#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<Team> teamLocker(team);
|
||||
Thread* thread = team->ThreadByID(fReportTargetThread);
|
||||
if (thread == NULL)
|
||||
return false;
|
||||
|
||||
return thread->State() != THREAD_STATE_STOPPED;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user