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 scrollHorizontal (ssize_t columns)
 
void horizontalScrollTo (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
 
virtual size_t getContentWidth ()
 

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
 
LockDescriptor * m_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
 
size_t m_column
 
char m_ScrollUp
 
char m_ScrollDown
 

Detailed Description

Traces lock allocations.

Definition at line 53 of file LocksCommand.h.

Member Enumeration Documentation

◆ State

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 123 of file LocksCommand.h.

Constructor & Destructor Documentation

◆ LocksCommand()

LocksCommand::LocksCommand ( )

Default constructor - zeroes stuff.

Definition at line 44 of file LocksCommand.cc.

References m_NextPosition.

◆ ~LocksCommand()

LocksCommand::~LocksCommand ( )
virtual

Default destructor - does nothing.

Definition at line 56 of file LocksCommand.cc.

Member Function Documentation

◆ autocomplete()

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

Return an autocomplete string, given an input string.

Implements DebuggerCommand.

Definition at line 58 of file LocksCommand.cc.

◆ checkSchedule()

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 430 of file LocksCommand.cc.

References Hex, ProcessorBase::index(), and m_NextPosition.

Referenced by PerProcessorScheduler::addThread(), and PerProcessorScheduler::addThread().

+ Here is the caller graph for this function:

◆ checkState()

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 452 of file LocksCommand.cc.

References Acquired, Attempted, Hex, Inactive, ProcessorBase::index(), m_NextPosition, and ProcessorBase::pause().

Referenced by Spinlock::acquireContended().

+ Here is the caller graph for this function:

◆ clearFatal()

void LocksCommand::clearFatal ( )
protected

Definition at line 307 of file LocksCommand.cc.

◆ execute()

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

Execute the command with the given screen.

Implements DebuggerCommand.

Definition at line 60 of file LocksCommand.cc.

References DebuggerIO::drawHorizontalLine(), DebuggerIO::drawString(), DebuggerIO::enableCli(), DebuggerIO::getChar(), and DebuggerIO::getWidth().

◆ getLine1()

const char * LocksCommand::getLine1 ( size_t  index,
DebuggerIO::Colour &  colour,
DebuggerIO::Colour &  bgColour 
)
virtual

Implements Scrollable.

Definition at line 147 of file LocksCommand.cc.

◆ getLine2()

const char * LocksCommand::getLine2 ( size_t  index,
size_t &  colOffset,
DebuggerIO::Colour &  colour,
DebuggerIO::Colour &  bgColour 
)
virtual

Implements Scrollable.

Definition at line 207 of file LocksCommand.cc.

◆ getLineCount()

size_t LocksCommand::getLineCount ( )
virtual

Implements Scrollable.

Definition at line 284 of file LocksCommand.cc.

◆ getString()

const NormalStaticString LocksCommand::getString ( )
inlinevirtual

Returns the string representation of this command.

Implements DebuggerCommand.

Definition at line 81 of file LocksCommand.h.

◆ lockAcquired()

bool LocksCommand::lockAcquired ( const Spinlock *  pLock,
size_t  nCpu = ~0U,
bool  intState = false 
)

Definition at line 349 of file LocksCommand.cc.

◆ lockAttempted()

bool LocksCommand::lockAttempted ( const Spinlock *  pLock,
size_t  nCpu = ~0U,
bool  intState = false 
)

Definition at line 311 of file LocksCommand.cc.

◆ lockReleased()

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

Definition at line 382 of file LocksCommand.cc.

References Acquired, Hex, Inactive, ProcessorBase::index(), and m_NextPosition.

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

+ Here is the caller graph for this function:

◆ setFatal()

void LocksCommand::setFatal ( )

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

Definition at line 303 of file LocksCommand.cc.

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

+ Here is the caller graph for this function:

◆ setReady()

void LocksCommand::setReady ( )

Definition at line 299 of file LocksCommand.cc.

◆ stateName()

const char * LocksCommand::stateName ( State  s)
inlineprivate

Definition at line 134 of file LocksCommand.h.

Friends And Related Symbol Documentation

◆ Spinlock

friend class Spinlock
friend

Definition at line 54 of file LocksCommand.h.

Member Data Documentation

◆ m_bAcquiring

Atomic<bool> LocksCommand::m_bAcquiring
private

Definition at line 158 of file LocksCommand.h.

◆ m_bFatal

bool LocksCommand::m_bFatal
private

Definition at line 163 of file LocksCommand.h.

◆ m_LockIndex

Atomic<size_t> LocksCommand::m_LockIndex
private

Definition at line 161 of file LocksCommand.h.

◆ m_NextPosition

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

Definition at line 160 of file LocksCommand.h.

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

◆ m_pDescriptors

LockDescriptor LocksCommand::m_pDescriptors[LOCKS_COMMAND_NUM_CPU][MAX_DESCRIPTORS]
private

Definition at line 156 of file LocksCommand.h.

◆ m_pSelectedLock

LockDescriptor* LocksCommand::m_pSelectedLock
private

Lock we've selected for backtracing.

Definition at line 168 of file LocksCommand.h.

◆ m_SelectedLine

size_t LocksCommand::m_SelectedLine
private

Definition at line 165 of file LocksCommand.h.


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