Debugger: Cleanup.

TargetHostInterface:
- Adjust _StartTeamDebugger to always require a user interface object to
  be passed in rather than implicitly falling back to GUI if unspecified.

Debugger:
- Refactor to be in compliance with the above.
This commit is contained in:
Rene Gollent
2016-05-22 15:57:10 -04:00
parent 836a148321
commit 880a646413
2 changed files with 27 additions and 14 deletions
+24 -4
View File
@@ -418,10 +418,17 @@ Debugger::MessageReceived(BMessage* message)
options.requestType = TEAM_DEBUGGER_REQUEST_ATTACH; options.requestType = TEAM_DEBUGGER_REQUEST_ATTACH;
options.settingsManager = &fSettingsManager; options.settingsManager = &fSettingsManager;
options.team = teamID; options.team = teamID;
options.userInterface = new(std::nothrow) GraphicalUserInterface;
if (options.userInterface == NULL) {
// TODO: notify user.
break;
}
BReference<UserInterface> uiReference(options.userInterface, true);
status_t error = interface->StartTeamDebugger(options); status_t error = interface->StartTeamDebugger(options);
if (error != B_OK) { if (error != B_OK) {
// TODO: notify user. // TODO: notify user.
} } else
uiReference.Detach();
break; break;
} }
case MSG_START_NEW_TEAM: case MSG_START_NEW_TEAM:
@@ -576,6 +583,10 @@ Debugger::_StartNewTeam(TargetHostInterface* interface, const char* path,
TeamDebuggerOptions options; TeamDebuggerOptions options;
options.requestType = TEAM_DEBUGGER_REQUEST_CREATE; options.requestType = TEAM_DEBUGGER_REQUEST_CREATE;
options.settingsManager = &fSettingsManager; options.settingsManager = &fSettingsManager;
options.userInterface = new(std::nothrow) GraphicalUserInterface;
if (options.userInterface == NULL)
return B_NO_MEMORY;
BReference<UserInterface> uiReference(options.userInterface, true);
options.commandLineArgc = argVector.ArgumentCount(); options.commandLineArgc = argVector.ArgumentCount();
if (options.commandLineArgc <= 0) if (options.commandLineArgc <= 0)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -586,8 +597,10 @@ Debugger::_StartNewTeam(TargetHostInterface* interface, const char* path,
MemoryDeleter deleter(argv); MemoryDeleter deleter(argv);
status_t error = interface->StartTeamDebugger(options); status_t error = interface->StartTeamDebugger(options);
if (error == B_OK) if (error == B_OK) {
deleter.Detach(); deleter.Detach();
uiReference.Detach();
}
return error; return error;
} }
@@ -599,10 +612,17 @@ Debugger::_HandleOptions(const Options& options)
TeamDebuggerOptions debuggerOptions; TeamDebuggerOptions debuggerOptions;
set_debugger_options_from_options(debuggerOptions, options); set_debugger_options_from_options(debuggerOptions, options);
debuggerOptions.settingsManager = &fSettingsManager; debuggerOptions.settingsManager = &fSettingsManager;
debuggerOptions.userInterface = new(std::nothrow) GraphicalUserInterface;
if (debuggerOptions.userInterface == NULL)
return B_NO_MEMORY;
BReference<UserInterface> uiReference(debuggerOptions.userInterface, true);
TargetHostInterface* hostInterface TargetHostInterface* hostInterface
= TargetHostInterfaceRoster::Default()->ActiveInterfaceAt(0); = TargetHostInterfaceRoster::Default()->ActiveInterfaceAt(0);
return hostInterface->StartTeamDebugger(debuggerOptions); status_t error = hostInterface->StartTeamDebugger(debuggerOptions);
if (error == B_OK)
uiReference.Detach();
return error;
} }
@@ -10,7 +10,6 @@
#include <AutoLocker.h> #include <AutoLocker.h>
#include "DebuggerInterface.h" #include "DebuggerInterface.h"
#include "GraphicalUserInterface.h"
#include "MessageCodes.h" #include "MessageCodes.h"
#include "TeamDebugger.h" #include "TeamDebugger.h"
@@ -238,16 +237,11 @@ status_t
TargetHostInterface::_StartTeamDebugger(team_id teamID, TargetHostInterface::_StartTeamDebugger(team_id teamID,
const TeamDebuggerOptions& options, bool stopInMain) const TeamDebuggerOptions& options, bool stopInMain)
{ {
BReference<UserInterface> userInterfaceReference;
UserInterface* userInterface = options.userInterface; UserInterface* userInterface = options.userInterface;
if (userInterface == NULL) { if (userInterface == NULL) {
userInterface = new(std::nothrow) GraphicalUserInterface; fprintf(stderr, "Error: Requested team debugger start without "
if (userInterface == NULL) { "valid user interface!\n");
fprintf(stderr, "Error: Out of memory!\n"); return B_BAD_VALUE;
return B_NO_MEMORY;
}
userInterfaceReference.SetTo(userInterface, true);
} }
thread_id threadID = options.thread; thread_id threadID = options.thread;
@@ -273,7 +267,6 @@ TargetHostInterface::_StartTeamDebugger(team_id teamID,
} }
} }
BReference<DebuggerInterface> debuggerInterfaceReference(interface, BReference<DebuggerInterface> debuggerInterfaceReference(interface,
true); true);
debugger = new(std::nothrow) TeamDebugger(this, userInterface, debugger = new(std::nothrow) TeamDebugger(this, userInterface,