Debugger: Change user interface quit and ask user semantics
* UserInterface::SynchronouslyAskUser() is now allowed to return -1 to indicate that the user cannot be asked at this point for whatever reason. The caller needs to handle that case. * UserInterfaceListener::UserInterfaceQuitRequested(): Add new parameter "quitOption" to specify what is supposed to happen. The previous behavior (ask user) is only one of the options. The others are to kill the debugged team or to resume it.
This commit is contained in:
@@ -707,39 +707,56 @@ TeamDebugger::InspectRequested(target_addr_t address,
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TeamDebugger::UserInterfaceQuitRequested()
|
TeamDebugger::UserInterfaceQuitRequested(QuitOption quitOption)
|
||||||
{
|
{
|
||||||
AutoLocker< ::Team> locker(fTeam);
|
bool askUser = false;
|
||||||
BString name(fTeam->Name());
|
switch (quitOption) {
|
||||||
locker.Unlock();
|
case QUIT_OPTION_ASK_USER:
|
||||||
|
askUser = true;
|
||||||
|
break;
|
||||||
|
|
||||||
BString message;
|
case QUIT_OPTION_ASK_KILL_TEAM:
|
||||||
message << "What shall be done about the debugged team '";
|
|
||||||
message << name;
|
|
||||||
message << "'?";
|
|
||||||
|
|
||||||
name.Remove(0, name.FindLast('/') + 1);
|
|
||||||
|
|
||||||
BString killLabel("Kill ");
|
|
||||||
killLabel << name;
|
|
||||||
|
|
||||||
BString resumeLabel("Resume ");
|
|
||||||
resumeLabel << name;
|
|
||||||
|
|
||||||
int32 choice = fUserInterface->SynchronouslyAskUser("Quit Debugger",
|
|
||||||
message, killLabel, "Cancel", resumeLabel);
|
|
||||||
|
|
||||||
switch (choice) {
|
|
||||||
case 0:
|
|
||||||
fKillTeamOnQuit = true;
|
fKillTeamOnQuit = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
|
||||||
return false;
|
case QUIT_OPTION_ASK_RESUME_TEAM:
|
||||||
case 2:
|
|
||||||
// Detach from the team and resume and stopped threads.
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (askUser) {
|
||||||
|
AutoLocker< ::Team> locker(fTeam);
|
||||||
|
BString name(fTeam->Name());
|
||||||
|
locker.Unlock();
|
||||||
|
|
||||||
|
BString message;
|
||||||
|
message << "What shall be done about the debugged team '";
|
||||||
|
message << name;
|
||||||
|
message << "'?";
|
||||||
|
|
||||||
|
name.Remove(0, name.FindLast('/') + 1);
|
||||||
|
|
||||||
|
BString killLabel("Kill ");
|
||||||
|
killLabel << name;
|
||||||
|
|
||||||
|
BString resumeLabel("Resume ");
|
||||||
|
resumeLabel << name;
|
||||||
|
|
||||||
|
int32 choice = fUserInterface->SynchronouslyAskUser("Quit Debugger",
|
||||||
|
message, killLabel, "Cancel", resumeLabel);
|
||||||
|
|
||||||
|
switch (choice) {
|
||||||
|
case 0:
|
||||||
|
fKillTeamOnQuit = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case -1:
|
||||||
|
return false;
|
||||||
|
case 2:
|
||||||
|
// Detach from the team and resume and stopped threads.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ private:
|
|||||||
UserBreakpoint* breakpoint);
|
UserBreakpoint* breakpoint);
|
||||||
virtual void InspectRequested(target_addr_t address,
|
virtual void InspectRequested(target_addr_t address,
|
||||||
TeamMemoryBlock::Listener* listener);
|
TeamMemoryBlock::Listener* listener);
|
||||||
virtual bool UserInterfaceQuitRequested();
|
virtual bool UserInterfaceQuitRequested(
|
||||||
|
QuitOption quitOption);
|
||||||
|
|
||||||
// JobListener
|
// JobListener
|
||||||
virtual void JobDone(Job* job);
|
virtual void JobDone(Job* job);
|
||||||
|
|||||||
@@ -61,10 +61,19 @@ public:
|
|||||||
const char* message, const char* choice1,
|
const char* message, const char* choice1,
|
||||||
const char* choice2, const char* choice3)
|
const char* choice2, const char* choice3)
|
||||||
= 0;
|
= 0;
|
||||||
|
// returns -1, if not implemented or user
|
||||||
|
// cannot be asked
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class UserInterfaceListener {
|
class UserInterfaceListener {
|
||||||
|
public:
|
||||||
|
enum QuitOption {
|
||||||
|
QUIT_OPTION_ASK_USER,
|
||||||
|
QUIT_OPTION_ASK_KILL_TEAM,
|
||||||
|
QUIT_OPTION_ASK_RESUME_TEAM
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~UserInterfaceListener();
|
virtual ~UserInterfaceListener();
|
||||||
|
|
||||||
@@ -95,7 +104,9 @@ public:
|
|||||||
target_addr_t address,
|
target_addr_t address,
|
||||||
TeamMemoryBlock::Listener* listener) = 0;
|
TeamMemoryBlock::Listener* listener) = 0;
|
||||||
|
|
||||||
virtual bool UserInterfaceQuitRequested() = 0;
|
virtual bool UserInterfaceQuitRequested(
|
||||||
|
QuitOption quitOption
|
||||||
|
= QUIT_OPTION_ASK_USER) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ CommandLineUserInterface::SynchronouslyAskUser(const char* title,
|
|||||||
const char* message, const char* choice1, const char* choice2,
|
const char* message, const char* choice1, const char* choice2,
|
||||||
const char* choice3)
|
const char* choice3)
|
||||||
{
|
{
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user