Debugger: Fix handling of team_id clashes.
TeamDebugger: - Add accessor to query whether the debugger's interface is a post mortem core rather than a live team. TargetHostInterface: - When asked to locate a team debugger by team_id, as is done for attach requests to determine if we already have an existing instance attached, skip over post mortems. This takes care of the potential problem of detecting a core instance with the same team_id as a live team, and consequently refusing the attach request. - When a team debugger quits, use its actual pointer to look it up rather than its team ID, as we could otherwise potentially remove the wrong one in the case of a clash.
This commit is contained in:
parent
2c4195e840
commit
61f0bf59fb
@ -218,6 +218,7 @@ TeamDebugger::TeamDebugger(Listener* listener, UserInterface* userInterface,
|
|||||||
fSettingsManager(settingsManager),
|
fSettingsManager(settingsManager),
|
||||||
fTeam(NULL),
|
fTeam(NULL),
|
||||||
fTeamID(-1),
|
fTeamID(-1),
|
||||||
|
fIsPostMortem(false),
|
||||||
fImageHandlers(NULL),
|
fImageHandlers(NULL),
|
||||||
fImageInfoPendingThreads(NULL),
|
fImageInfoPendingThreads(NULL),
|
||||||
fDebuggerInterface(NULL),
|
fDebuggerInterface(NULL),
|
||||||
@ -337,6 +338,7 @@ TeamDebugger::Init(DebuggerInterface* interface, thread_id threadID, int argc,
|
|||||||
fDebuggerInterface = interface;
|
fDebuggerInterface = interface;
|
||||||
fDebuggerInterface->AcquireReference();
|
fDebuggerInterface->AcquireReference();
|
||||||
fTeamID = interface->TeamID();
|
fTeamID = interface->TeamID();
|
||||||
|
fIsPostMortem = interface->IsPostMortem();
|
||||||
|
|
||||||
|
|
||||||
// create file manager
|
// create file manager
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
|
|
||||||
team_id TeamID() const { return fTeamID; }
|
team_id TeamID() const { return fTeamID; }
|
||||||
|
|
||||||
|
bool IsPostMortem() const { return fIsPostMortem; }
|
||||||
|
|
||||||
int ArgumentCount() const
|
int ArgumentCount() const
|
||||||
{ return fCommandLineArgc; }
|
{ return fCommandLineArgc; }
|
||||||
const char** Arguments() const
|
const char** Arguments() const
|
||||||
@ -245,6 +247,7 @@ private:
|
|||||||
SettingsManager* fSettingsManager;
|
SettingsManager* fSettingsManager;
|
||||||
::Team* fTeam;
|
::Team* fTeam;
|
||||||
team_id fTeamID;
|
team_id fTeamID;
|
||||||
|
bool fIsPostMortem;
|
||||||
ThreadHandlerTable fThreadHandlers;
|
ThreadHandlerTable fThreadHandlers;
|
||||||
// protected by the team lock
|
// protected by the team lock
|
||||||
ImageHandlerTable* fImageHandlers;
|
ImageHandlerTable* fImageHandlers;
|
||||||
|
@ -110,7 +110,13 @@ TargetHostInterface::TeamDebuggerAt(int32 index) const
|
|||||||
TeamDebugger*
|
TeamDebugger*
|
||||||
TargetHostInterface::FindTeamDebugger(team_id team) const
|
TargetHostInterface::FindTeamDebugger(team_id team) const
|
||||||
{
|
{
|
||||||
return fTeamDebuggers.BinarySearchByKey(team, &_FindDebuggerByKey);
|
for (int32 i = 0; i < fTeamDebuggers.CountItems(); i++) {
|
||||||
|
TeamDebugger* debugger = fTeamDebuggers.ItemAt(i);
|
||||||
|
if (debugger->TeamID() == team && !debugger->IsPostMortem())
|
||||||
|
return debugger;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,10 +133,12 @@ TargetHostInterface::AddTeamDebugger(TeamDebugger* debugger)
|
|||||||
void
|
void
|
||||||
TargetHostInterface::RemoveTeamDebugger(TeamDebugger* debugger)
|
TargetHostInterface::RemoveTeamDebugger(TeamDebugger* debugger)
|
||||||
{
|
{
|
||||||
int32 index = fTeamDebuggers.BinarySearchIndexByKey(debugger->TeamID(),
|
for (int32 i = 0; i < fTeamDebuggers.CountItems(); i++) {
|
||||||
&_FindDebuggerByKey);
|
if (fTeamDebuggers.ItemAt(i) == debugger) {
|
||||||
if (index >= 0)
|
fTeamDebuggers.RemoveItemAt(i);
|
||||||
fTeamDebuggers.RemoveItemAt(index);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,18 +325,6 @@ TargetHostInterface::_CompareDebuggers(const TeamDebugger* a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*static*/ int
|
|
||||||
TargetHostInterface::_FindDebuggerByKey(const team_id* team,
|
|
||||||
const TeamDebugger* debugger)
|
|
||||||
{
|
|
||||||
if (*team < debugger->TeamID())
|
|
||||||
return -1;
|
|
||||||
else if (*team > debugger->TeamID())
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - TargetHostInterface::Listener
|
// #pragma mark - TargetHostInterface::Listener
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,8 +84,6 @@ private:
|
|||||||
|
|
||||||
static int _CompareDebuggers(const TeamDebugger* a,
|
static int _CompareDebuggers(const TeamDebugger* a,
|
||||||
const TeamDebugger* b);
|
const TeamDebugger* b);
|
||||||
static int _FindDebuggerByKey(const team_id* team,
|
|
||||||
const TeamDebugger* debugger);
|
|
||||||
private:
|
private:
|
||||||
typedef DoublyLinkedList<Listener> ListenerList;
|
typedef DoublyLinkedList<Listener> ListenerList;
|
||||||
typedef BObjectList<TeamDebugger> TeamDebuggerList;
|
typedef BObjectList<TeamDebugger> TeamDebuggerList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user