Debugger: Add signal settings and listener hooks.
Team: - Add settings and accessors for signal dispositions. - Add event definitions and listener hooks for signal disposition changes.
This commit is contained in:
@@ -27,6 +27,9 @@ enum {
|
||||
MSG_STOP_ON_IMAGE_LOAD = 'tsil',
|
||||
MSG_ADD_STOP_IMAGE_NAME = 'asin',
|
||||
MSG_REMOVE_STOP_IMAGE_NAME = 'rsin',
|
||||
MSG_SET_DEFAULT_SIGNAL_DISPOSITION = 'sdsd',
|
||||
MSG_SET_CUSTOM_SIGNAL_DISPOSITION = 'scsd',
|
||||
MSG_REMOVE_CUSTOM_SIGNAL_DISPOSITION = 'rcsd',
|
||||
|
||||
MSG_THREAD_STATE_CHANGED = 'tsch',
|
||||
MSG_THREAD_CPU_STATE_CHANGED = 'tcsc',
|
||||
|
||||
@@ -685,6 +685,43 @@ TeamDebugger::MessageReceived(BMessage* message)
|
||||
|
||||
AutoLocker< ::Team> teamLocker(fTeam);
|
||||
fTeam->RemoveStopImageName(imageName);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_SET_DEFAULT_SIGNAL_DISPOSITION:
|
||||
{
|
||||
int32 disposition;
|
||||
if (message->FindInt32("disposition", &disposition) != B_OK)
|
||||
break;
|
||||
|
||||
AutoLocker< ::Team> teamLocker(fTeam);
|
||||
fTeam->SetDefaultSignalDisposition(disposition);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_SET_CUSTOM_SIGNAL_DISPOSITION:
|
||||
{
|
||||
int32 signal;
|
||||
int32 disposition;
|
||||
if (message->FindInt32("signal", &signal) != B_OK
|
||||
|| message->FindInt32("disposition", &disposition) != B_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
AutoLocker< ::Team> teamLocker(fTeam);
|
||||
fTeam->SetCustomSignalDisposition(signal, disposition);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_REMOVE_CUSTOM_SIGNAL_DISPOSITION:
|
||||
{
|
||||
int32 signal;
|
||||
if (message->FindInt32("signal", &signal) != B_OK)
|
||||
break;
|
||||
|
||||
AutoLocker< ::Team> teamLocker(fTeam);
|
||||
fTeam->RemoveCustomSignalDisposition(signal);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_SET_WATCHPOINT:
|
||||
@@ -1105,6 +1142,35 @@ TeamDebugger::RemoveStopImageNameRequested(const char* name)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::SetDefaultSignalDispositionRequested(int32 disposition)
|
||||
{
|
||||
BMessage message(MSG_SET_DEFAULT_SIGNAL_DISPOSITION);
|
||||
message.AddInt32("disposition", disposition);
|
||||
PostMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::SetCustomSignalDispositionRequested(int32 signal,
|
||||
int32 disposition)
|
||||
{
|
||||
BMessage message(MSG_SET_CUSTOM_SIGNAL_DISPOSITION);
|
||||
message.AddInt32("signal", signal);
|
||||
message.AddInt32("disposition", disposition);
|
||||
PostMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::RemoveCustomSignalDispositionRequested(int32 signal)
|
||||
{
|
||||
BMessage message(MSG_REMOVE_CUSTOM_SIGNAL_DISPOSITION);
|
||||
message.AddInt32("signal", signal);
|
||||
PostMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamDebugger::ClearBreakpointRequested(UserBreakpoint* breakpoint)
|
||||
{
|
||||
|
||||
@@ -97,6 +97,13 @@ private:
|
||||
virtual void RemoveStopImageNameRequested(
|
||||
const char* name);
|
||||
|
||||
virtual void SetDefaultSignalDispositionRequested(
|
||||
int32 disposition);
|
||||
virtual void SetCustomSignalDispositionRequested(
|
||||
int32 signal, int32 disposition);
|
||||
virtual void RemoveCustomSignalDispositionRequested(
|
||||
int32 signal);
|
||||
|
||||
virtual void SetWatchpointRequested(target_addr_t address,
|
||||
uint32 type, int32 length, bool enabled);
|
||||
virtual void SetWatchpointEnabledRequested(
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "FileSourceCode.h"
|
||||
#include "Function.h"
|
||||
#include "ImageDebugInfo.h"
|
||||
#include "SignalDispositionTypes.h"
|
||||
#include "SourceCode.h"
|
||||
#include "SpecificImageDebugInfo.h"
|
||||
#include "Statement.h"
|
||||
@@ -80,7 +81,8 @@ Team::Team(team_id teamID, TeamMemory* teamMemory, Architecture* architecture,
|
||||
fArchitecture(architecture),
|
||||
fDebugInfo(debugInfo),
|
||||
fStopOnImageLoad(false),
|
||||
fStopImageNameListEnabled(false)
|
||||
fStopImageNameListEnabled(false),
|
||||
fDefaultSignalDisposition(SIGNAL_DISPOSITION_IGNORE)
|
||||
{
|
||||
fDebugInfo->AcquireReference();
|
||||
}
|
||||
@@ -312,6 +314,69 @@ Team::StopImageNames() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::SetDefaultSignalDisposition(int32 disposition)
|
||||
{
|
||||
if (disposition != fDefaultSignalDisposition) {
|
||||
fDefaultSignalDisposition = disposition;
|
||||
NotifyDefaultSignalDispositionChanged(disposition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Team::SetCustomSignalDisposition(int32 signal, int32 disposition)
|
||||
{
|
||||
SignalDispositionMappings::iterator it = fCustomSignalDispositions.find(
|
||||
signal);
|
||||
if (it != fCustomSignalDispositions.end() && it->second == disposition)
|
||||
return true;
|
||||
|
||||
try {
|
||||
fCustomSignalDispositions[signal] = disposition;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NotifyCustomSignalDispositionChanged(signal, disposition);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::RemoveCustomSignalDisposition(int32 signal)
|
||||
{
|
||||
SignalDispositionMappings::iterator it = fCustomSignalDispositions.find(
|
||||
signal);
|
||||
if (it == fCustomSignalDispositions.end())
|
||||
return;
|
||||
|
||||
fCustomSignalDispositions.erase(it);
|
||||
|
||||
NotifyCustomSignalDispositionRemoved(signal);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
Team::SignalDispositionFor(int32 signal) const
|
||||
{
|
||||
SignalDispositionMappings::const_iterator it
|
||||
= fCustomSignalDispositions.find(signal);
|
||||
if (it != fCustomSignalDispositions.end())
|
||||
return it->second;
|
||||
|
||||
return fDefaultSignalDisposition;
|
||||
}
|
||||
|
||||
|
||||
const SignalDispositionMappings&
|
||||
Team::GetSignalDispositionMappings() const
|
||||
{
|
||||
return fCustomSignalDispositions;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Team::AddBreakpoint(Breakpoint* breakpoint)
|
||||
{
|
||||
@@ -687,6 +752,45 @@ Team::NotifyStopImageNameRemoved(const BString& name)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::NotifyDefaultSignalDispositionChanged(int32 disposition)
|
||||
{
|
||||
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||
Listener* listener = it.Next();) {
|
||||
listener->DefaultSignalDispositionChanged(
|
||||
DefaultSignalDispositionEvent(
|
||||
TEAM_EVENT_DEFAULT_SIGNAL_DISPOSITION_CHANGED, this,
|
||||
disposition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::NotifyCustomSignalDispositionChanged(int32 signal, int32 disposition)
|
||||
{
|
||||
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||
Listener* listener = it.Next();) {
|
||||
listener->CustomSignalDispositionChanged(
|
||||
CustomSignalDispositionEvent(
|
||||
TEAM_EVENT_CUSTOM_SIGNAL_DISPOSITION_CHANGED, this,
|
||||
signal, disposition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::NotifyCustomSignalDispositionRemoved(int32 signal)
|
||||
{
|
||||
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||
Listener* listener = it.Next();) {
|
||||
listener->CustomSignalDispositionRemoved(
|
||||
CustomSignalDispositionEvent(
|
||||
TEAM_EVENT_CUSTOM_SIGNAL_DISPOSITION_REMOVED, this,
|
||||
signal, SIGNAL_DISPOSITION_IGNORE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::NotifyConsoleOutputReceived(int32 fd, const BString& output)
|
||||
{
|
||||
@@ -841,6 +945,31 @@ Team::ImageLoadNameEvent::ImageLoadNameEvent(uint32 type, Team* team,
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - DefaultSignalDispositionEvent
|
||||
|
||||
|
||||
Team::DefaultSignalDispositionEvent::DefaultSignalDispositionEvent(uint32 type,
|
||||
Team* team, int32 disposition)
|
||||
:
|
||||
Event(type, team),
|
||||
fDefaultDisposition(disposition)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - CustomSignalDispositionEvent
|
||||
|
||||
|
||||
Team::CustomSignalDispositionEvent::CustomSignalDispositionEvent(uint32 type,
|
||||
Team* team, int32 signal, int32 disposition)
|
||||
:
|
||||
Event(type, team),
|
||||
fSignal(signal),
|
||||
fDisposition(disposition)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BreakpointEvent
|
||||
|
||||
|
||||
@@ -991,6 +1120,27 @@ Team::Listener::StopOnImageLoadNameRemoved(
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::Listener::DefaultSignalDispositionChanged(
|
||||
const Team::DefaultSignalDispositionEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::Listener::CustomSignalDispositionChanged(
|
||||
const Team::CustomSignalDispositionEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::Listener::CustomSignalDispositionRemoved(
|
||||
const Team::CustomSignalDispositionEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Team::Listener::ConsoleOutputReceived(const Team::ConsoleOutputEvent& event)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2013-2014, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2013-2015, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TEAM_H
|
||||
#define TEAM_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Locker.h>
|
||||
#include <StringList.h>
|
||||
@@ -38,6 +39,10 @@ enum {
|
||||
TEAM_EVENT_IMAGE_LOAD_NAME_ADDED,
|
||||
TEAM_EVENT_IMAGE_LOAD_NAME_REMOVED,
|
||||
|
||||
TEAM_EVENT_DEFAULT_SIGNAL_DISPOSITION_CHANGED,
|
||||
TEAM_EVENT_CUSTOM_SIGNAL_DISPOSITION_CHANGED,
|
||||
TEAM_EVENT_CUSTOM_SIGNAL_DISPOSITION_REMOVED,
|
||||
|
||||
TEAM_EVENT_CONSOLE_OUTPUT_RECEIVED,
|
||||
|
||||
TEAM_EVENT_BREAKPOINT_ADDED,
|
||||
@@ -71,6 +76,9 @@ class UserBreakpoint;
|
||||
class Value;
|
||||
|
||||
|
||||
typedef std::map<int32, int32> SignalDispositionMappings;
|
||||
|
||||
|
||||
class Team {
|
||||
public:
|
||||
class Event;
|
||||
@@ -81,6 +89,8 @@ public:
|
||||
class ImageEvent;
|
||||
class ImageLoadEvent;
|
||||
class ImageLoadNameEvent;
|
||||
class DefaultSignalDispositionEvent;
|
||||
class CustomSignalDispositionEvent;
|
||||
class ThreadEvent;
|
||||
class UserBreakpointEvent;
|
||||
class WatchpointEvent;
|
||||
@@ -139,6 +149,18 @@ public:
|
||||
bool StopImageNameListEnabled() const
|
||||
{ return fStopImageNameListEnabled; }
|
||||
|
||||
void SetDefaultSignalDisposition(int32 disposition);
|
||||
int32 DefaultSignalDisposition() const
|
||||
{ return fDefaultSignalDisposition; }
|
||||
bool SetCustomSignalDisposition(int32 signal,
|
||||
int32 disposition);
|
||||
void RemoveCustomSignalDisposition(int32 signal);
|
||||
int32 SignalDispositionFor(int32 signal) const;
|
||||
// if no custom disposition is found,
|
||||
// returns default
|
||||
const SignalDispositionMappings&
|
||||
GetSignalDispositionMappings() const;
|
||||
|
||||
bool AddBreakpoint(Breakpoint* breakpoint);
|
||||
// takes over reference (also on error)
|
||||
void RemoveBreakpoint(Breakpoint* breakpoint);
|
||||
@@ -212,6 +234,14 @@ public:
|
||||
void NotifyStopImageNameRemoved(
|
||||
const BString& name);
|
||||
|
||||
// service methods for Signal Disposition settings
|
||||
void NotifyDefaultSignalDispositionChanged(
|
||||
int32 newDisposition);
|
||||
void NotifyCustomSignalDispositionChanged(
|
||||
int32 signal, int32 disposition);
|
||||
void NotifyCustomSignalDispositionRemoved(
|
||||
int32 signal);
|
||||
|
||||
// service methods for console output
|
||||
void NotifyConsoleOutputReceived(
|
||||
int32 fd, const BString& output);
|
||||
@@ -259,6 +289,9 @@ private:
|
||||
bool fStopOnImageLoad;
|
||||
bool fStopImageNameListEnabled;
|
||||
BStringList fStopImageNames;
|
||||
int32 fDefaultSignalDisposition;
|
||||
SignalDispositionMappings
|
||||
fCustomSignalDispositions;
|
||||
BreakpointList fBreakpoints;
|
||||
WatchpointList fWatchpoints;
|
||||
UserBreakpointList fUserBreakpoints;
|
||||
@@ -330,6 +363,34 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class Team::DefaultSignalDispositionEvent : public Event {
|
||||
public:
|
||||
DefaultSignalDispositionEvent(uint32 type,
|
||||
Team* team, int32 disposition);
|
||||
|
||||
int32 DefaultDisposition() const
|
||||
{ return fDefaultDisposition; }
|
||||
|
||||
private:
|
||||
int32 fDefaultDisposition;
|
||||
};
|
||||
|
||||
|
||||
class Team::CustomSignalDispositionEvent : public Event {
|
||||
public:
|
||||
CustomSignalDispositionEvent(uint32 type,
|
||||
Team* team, int32 signal,
|
||||
int32 disposition);
|
||||
|
||||
int32 Signal() const { return fSignal; }
|
||||
int32 Disposition() const { return fDisposition; }
|
||||
|
||||
private:
|
||||
int32 fSignal;
|
||||
int32 fDisposition;
|
||||
};
|
||||
|
||||
|
||||
class Team::BreakpointEvent : public Event {
|
||||
public:
|
||||
BreakpointEvent(uint32 type, Team* team,
|
||||
@@ -433,6 +494,16 @@ public:
|
||||
virtual void StopOnImageLoadNameRemoved(
|
||||
const Team::ImageLoadNameEvent& event);
|
||||
|
||||
virtual void DefaultSignalDispositionChanged(
|
||||
const Team::DefaultSignalDispositionEvent&
|
||||
event);
|
||||
virtual void CustomSignalDispositionChanged(
|
||||
const Team::CustomSignalDispositionEvent&
|
||||
event);
|
||||
virtual void CustomSignalDispositionRemoved(
|
||||
const Team::CustomSignalDispositionEvent&
|
||||
event);
|
||||
|
||||
virtual void ConsoleOutputReceived(
|
||||
const Team::ConsoleOutputEvent& event);
|
||||
|
||||
|
||||
@@ -128,6 +128,13 @@ public:
|
||||
virtual void RemoveStopImageNameRequested(
|
||||
const char* name) = 0;
|
||||
|
||||
virtual void SetDefaultSignalDispositionRequested(
|
||||
int32 disposition) = 0;
|
||||
virtual void SetCustomSignalDispositionRequested(
|
||||
int32 signal, int32 disposition) = 0;
|
||||
virtual void RemoveCustomSignalDispositionRequested(
|
||||
int32 signal) = 0;
|
||||
|
||||
virtual void SetWatchpointRequested(target_addr_t address,
|
||||
uint32 type, int32 length,
|
||||
bool enabled) = 0;
|
||||
|
||||
Reference in New Issue
Block a user