The Pedigree Project  0.1
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
LocksCommand Class Reference

#include <LocksCommand.h>

+ Inheritance diagram for LocksCommand:
+ Collaboration diagram for LocksCommand:

Classes

struct  LockDescriptor
 

Public Member Functions

 LocksCommand ()
 
virtual ~LocksCommand ()
 
void autocomplete (const HugeStaticString &input, HugeStaticString &output)
 
bool execute (const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
 
const NormalStaticString getString ()
 
void setReady ()
 
void setFatal ()
 
bool lockAttempted (const Spinlock *pLock, size_t nCpu=~0U, bool intState=false)
 
bool lockAcquired (const Spinlock *pLock, size_t nCpu=~0U, bool intState=false)
 
bool lockReleased (const Spinlock *pLock, size_t nCpu=~0U)
 
bool checkSchedule (size_t nCpu=~0U)
 
bool checkState (const Spinlock *pLock, size_t nCpu=~0U)
 
virtual const char * getLine1 (size_t index, DebuggerIO::Colour &colour, DebuggerIO::Colour &bgColour)
 
virtual const char * getLine2 (size_t index, size_t &colOffset, DebuggerIO::Colour &colour, DebuggerIO::Colour &bgColour)
 
virtual size_t getLineCount ()
 
- Public Member Functions inherited from Scrollable
void move (size_t x, size_t y)
 
void resize (size_t width, size_t height)
 
void scroll (ssize_t lines)
 
void scrollTo (size_t absolute)
 
void refresh (DebuggerIO *pScreen)
 
void setScrollKeys (char up, char down)
 
ssize_t getLine ()
 
void centreOn (size_t line)
 
size_t height () const
 
size_t width () const
 

Protected Member Functions

void clearFatal ()
 

Private Types

enum  State { Inactive = 0, Attempted, Acquired, Checked }
 

Private Member Functions

const char * stateName (State s)
 

Private Attributes

LockDescriptor m_pDescriptors [LOCKS_COMMAND_NUM_CPU][MAX_DESCRIPTORS]
 
Atomic< bool > m_bAcquiring
 
Atomic< uint8_t > m_NextPosition [LOCKS_COMMAND_NUM_CPU]
 
Atomic< size_t > m_LockIndex
 
bool m_bFatal
 
size_t m_SelectedLine
 
LockDescriptorm_pSelectedLock
 Lock we've selected for backtracing.
 

Friends

class Spinlock
 

Additional Inherited Members

- Protected Attributes inherited from Scrollable
size_t m_x
 
size_t m_y
 
size_t m_width
 
size_t m_height
 
ssize_t m_line
 
char m_ScrollUp
 
char m_ScrollDown
 

Detailed Description

Traces lock allocations.

Definition at line 54 of file LocksCommand.h.

Member Enumeration Documentation

enum LocksCommand::State
private
Enumerator
Inactive 

This entry is no longer active.

Attempted 

The lock is about to be attempted.

Acquired 

The lock is acquired.

Checked 

The lock failed to be acquired, and has been checked once.

Definition at line 130 of file LocksCommand.h.

Constructor & Destructor Documentation

LocksCommand::LocksCommand ( )

Default constructor - zeroes stuff.

Definition at line 50 of file LocksCommand.cc.

References m_NextPosition.

LocksCommand::~LocksCommand ( )
virtual

Default destructor - does nothing.

Definition at line 63 of file LocksCommand.cc.

Member Function Documentation

void LocksCommand::autocomplete ( const HugeStaticString input,
HugeStaticString output 
)
virtual

Return an autocomplete string, given an input string.

Implements DebuggerCommand.

Definition at line 67 of file LocksCommand.cc.

bool LocksCommand::checkSchedule ( size_t  nCpu = ~0U)

Notifies the command that a core is about to reschedule.

Note: NO locks should be held across a reschedule.

Definition at line 603 of file LocksCommand.cc.

References Processor::id(), and m_NextPosition.

Referenced by PerProcessorScheduler::addThread(), getString(), PerProcessorScheduler::killCurrentThread(), and PerProcessorScheduler::schedule().

+ Here is the caller graph for this function:

bool LocksCommand::checkState ( const Spinlock pLock,
size_t  nCpu = ~0U 
)

Notifies the command that we'd like to lock the given lock, allowing the LocksCommand instance to detect common concurrency issues like dependency inversion. This should be called after an acquire() fails, as it may have undesirable overhead for the "perfect" case.

Definition at line 622 of file LocksCommand.cc.

References Acquired, Attempted, Hex, Processor::id(), Inactive, m_NextPosition, and Processor::pause().

Referenced by Spinlock::acquire(), and getString().

+ Here is the caller graph for this function:

bool LocksCommand::execute ( const HugeStaticString input,
HugeStaticString output,
InterruptState &  state,
DebuggerIO screen 
)
virtual
const NormalStaticString LocksCommand::getString ( )
inlinevirtual

Returns the string representation of this command.

Implements DebuggerCommand.

Definition at line 84 of file LocksCommand.h.

References checkSchedule(), checkState(), lockReleased(), and setFatal().

bool LocksCommand::lockReleased ( const Spinlock pLock,
size_t  nCpu = ~0U 
)
Todo:
not SMP-safe...

Definition at line 546 of file LocksCommand.cc.

References Acquired, Hex, Processor::id(), Inactive, and m_NextPosition.

Referenced by PerProcessorScheduler::addThread(), getString(), PerProcessorScheduler::killCurrentThread(), PerProcessorScheduler::schedule(), and Spinlock::trackRelease().

+ Here is the caller graph for this function:

void LocksCommand::setFatal ( )

LocksCommand defaults to logging errors and returning failure. Call this to change it to logging fatal errors itself.

Definition at line 420 of file LocksCommand.cc.

References Acquired, Attempted, Dec, Backtrace::getReturnAddress(), Hex, Processor::id(), Inactive, Processor::isInitialised(), m_NextPosition, Backtrace::numStackFrames(), and Backtrace::performBpBacktrace().

Referenced by Spinlock::acquire(), getString(), and Spinlock::trackRelease().

+ Here is the caller graph for this function:

Member Data Documentation

Atomic<uint8_t> LocksCommand::m_NextPosition[LOCKS_COMMAND_NUM_CPU]
private
Note
locking up to 256 levels deep can be tracked

Definition at line 185 of file LocksCommand.h.

Referenced by checkSchedule(), checkState(), execute(), lockReleased(), LocksCommand(), and setFatal().


The documentation for this class was generated from the following files: