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
|
// create the command line UI
|
||||||
CommandLineUserInterface* userInterface
|
CommandLineUserInterface* userInterface
|
||||||
= new(std::nothrow) CommandLineUserInterface(options.saveReport,
|
= new(std::nothrow) CommandLineUserInterface(options.saveReport,
|
||||||
options.reportPath);
|
options.reportPath, options.thread);
|
||||||
if (userInterface == NULL) {
|
if (userInterface == NULL) {
|
||||||
fprintf(stderr, "Error: Out of memory!\n");
|
fprintf(stderr, "Error: Out of memory!\n");
|
||||||
return false;
|
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].
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <ArgumentVector.h>
|
#include <ArgumentVector.h>
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
#include <AutoLocker.h>
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
|
|
||||||
#include "CliContext.h"
|
#include "CliContext.h"
|
||||||
@@ -93,11 +94,12 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
CommandLineUserInterface::CommandLineUserInterface(bool saveReport,
|
CommandLineUserInterface::CommandLineUserInterface(bool saveReport,
|
||||||
const char* reportPath)
|
const char* reportPath, thread_id reportTargetThread)
|
||||||
:
|
:
|
||||||
fCommands(20, true),
|
fCommands(20, true),
|
||||||
fReportPath(reportPath),
|
fReportPath(reportPath),
|
||||||
fSaveReport(saveReport),
|
fSaveReport(saveReport),
|
||||||
|
fReportTargetThread(reportTargetThread),
|
||||||
fShowSemaphore(-1),
|
fShowSemaphore(-1),
|
||||||
fShown(false),
|
fShown(false),
|
||||||
fTerminating(false)
|
fTerminating(false)
|
||||||
@@ -219,6 +221,12 @@ CommandLineUserInterface::Run()
|
|||||||
ArgumentVector args;
|
ArgumentVector args;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
const char* parseErrorLocation;
|
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",
|
snprintf(buffer, sizeof(buffer), "save-report %s",
|
||||||
fReportPath != NULL ? fReportPath : "");
|
fReportPath != NULL ? fReportPath : "");
|
||||||
args.Parse(buffer, &parseErrorLocation);
|
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, [email protected].
|
* Copyright 2011-2013, Rene Gollent, [email protected].
|
||||||
* Copyright 2012, Ingo Weinhold, [email protected].
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -21,7 +21,8 @@ class CommandLineUserInterface : public UserInterface,
|
|||||||
public ::Team::Listener {
|
public ::Team::Listener {
|
||||||
public:
|
public:
|
||||||
CommandLineUserInterface(bool saveReport,
|
CommandLineUserInterface(bool saveReport,
|
||||||
const char* reportPath);
|
const char* reportPath,
|
||||||
|
thread_id reportTargetThread);
|
||||||
virtual ~CommandLineUserInterface();
|
virtual ~CommandLineUserInterface();
|
||||||
|
|
||||||
virtual const char* ID() const;
|
virtual const char* ID() const;
|
||||||
@@ -76,11 +77,14 @@ private:
|
|||||||
const CommandEntry* command1,
|
const CommandEntry* command1,
|
||||||
const CommandEntry* command2);
|
const CommandEntry* command2);
|
||||||
|
|
||||||
|
bool _ReportTargetThreadStopNeeded() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CliContext fContext;
|
CliContext fContext;
|
||||||
CommandList fCommands;
|
CommandList fCommands;
|
||||||
const char* fReportPath;
|
const char* fReportPath;
|
||||||
bool fSaveReport;
|
bool fSaveReport;
|
||||||
|
thread_id fReportTargetThread;
|
||||||
sem_id fShowSemaphore;
|
sem_id fShowSemaphore;
|
||||||
bool fShown;
|
bool fShown;
|
||||||
volatile bool fTerminating;
|
volatile bool fTerminating;
|
||||||
|
|||||||
Reference in New Issue
Block a user