123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 |
- /*++
- Copyright (c) 2012 Minoca Corp. All Rights Reserved
- Module Name:
- console.h
- Abstract:
- This header contains definitions for the generic console functions required
- by the debugger.
- Author:
- Evan Green 2-Jul-2012
- --*/
- //
- // ---------------------------------------------------------------- Definitions
- //
- #define KEY_RETURN 0x10
- #define KEY_UP 0x01
- #define KEY_DOWN 0x02
- #define KEY_ESCAPE 0x03
- #define KEY_REMOTE 0x04
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- typedef
- VOID
- (*PDBGR_THREAD_ROUTINE) (
- PVOID Parameter
- );
- /*++
- Routine Description:
- This routine is the entry point prototype for a new thread.
- Arguments:
- Parameter - Supplies a pointer supplied by the creator of the thread.
- Return Value:
- None.
- --*/
- //
- // -------------------------------------------------------- Function Prototypes
- //
- //
- // Functions callable by the OS support layer.
- //
- INT
- DbgrMain (
- INT ArgumentCount,
- CHAR **Arguments
- );
- /*++
- Routine Description:
- This routine is the main entry point for the debugger.
- Arguments:
- ArgumentCount - Supplies the number of arguments on the command line.
- Arguments - Supplies an array of strings representing the arguments.
- Return Value:
- Returns 0 on success, nonzero on failure.
- --*/
- VOID
- DbgrRequestBreakIn (
- VOID
- );
- /*++
- Routine Description:
- This routine sends a break-in request to the target.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- VOID
- DbgrDisplayCommandLineProfilerData (
- PROFILER_DATA_TYPE DataType,
- PROFILER_DISPLAY_REQUEST DisplayRequest,
- ULONG Threshold
- );
- /*++
- Routine Description:
- This routine displays the profiler data collected by the core debugging
- infrastructure to standard out.
- Arguments:
- DataType - Supplies the type of profiler data that is to be displayed.
- DisplayRequest - Supplies a value requesting a display action, which can
- either be to display data once, continually, or to stop continually
- displaying data.
- Threshold - Supplies the minimum percentage a stack entry hit must be in
- order to be displayed.
- Return Value:
- None.
- --*/
- BOOL
- DbgrGetProfilerStackData (
- PSTACK_DATA_ENTRY *StackTreeRoot
- );
- /*++
- Routine Description:
- This routine processes and returns any pending profiling stack data. It
- will add it to the provided stack tree root. The caller is responsible for
- destroying the tree.
- Arguments:
- StackTreeRoot - Supplies a pointer to a pointer to the root of the stack
- data tree. Upon return from the routine it will be updated with all the
- newly parsed data. If the root is null, a new root will be allocated.
- Return Value:
- Returns TRUE when data is successfully returned, or FALSE on failure.
- --*/
- VOID
- DbgrDestroyProfilerStackData (
- PSTACK_DATA_ENTRY Root
- );
- /*++
- Routine Description:
- This routine destroys a profiler stack data tree.
- Arguments:
- Root - Supplies a pointer to the root element of the tree.
- Return Value:
- None.
- --*/
- VOID
- DbgrPrintProfilerStackData (
- PSTACK_DATA_ENTRY Root,
- ULONG Threshold
- );
- /*++
- Routine Description:
- This routine prints profiler stack data to standard out.
- Arguments:
- Root - Supplies a pointer to the root of the profiler stack data tree.
- Threshold - Supplies the minimum percentage a stack entry hit must be in
- order to be displayed.
- Return Value:
- None.
- --*/
- VOID
- DbgrProfilerStackEntrySelected (
- PSTACK_DATA_ENTRY Root
- );
- /*++
- Routine Description:
- This routine is called when a profiler stack data entry is selected by the
- user.
- Arguments:
- Root - Supplies a pointer to the root of the profiler stack data tree.
- Return Value:
- None.
- --*/
- BOOL
- DbgrGetProfilerMemoryData (
- PLIST_ENTRY *MemoryPoolListHead
- );
- /*++
- Routine Description:
- This routine processes and returns any pending profiling memory data.
- Arguments:
- MemoryPoolListHead - Supplies a pointer to head of the memory pool list
- that is to be populated with the most up to date pool data.
- Return Value:
- Returns TRUE when data is successfully returned, or FALSE on failure.
- --*/
- VOID
- DbgrDestroyProfilerMemoryData (
- PLIST_ENTRY PoolListHead
- );
- /*++
- Routine Description:
- This routine destroys a profiler memory data list.
- Arguments:
- PoolListHead - Supplies a pointer to the head of the memory pool list
- that is to be destroyed.
- Return Value:
- None.
- --*/
- VOID
- DbgrPrintProfilerMemoryData (
- PLIST_ENTRY MemoryPoolListHead,
- BOOL DeltaMode,
- ULONG ActiveCountThreshold
- );
- /*++
- Routine Description:
- This routine prints the statistics from the given memory pool list to the
- debugger console.
- Arguments:
- MemoryPoolListHead - Supplies a pointer to the head of the memory pool
- list.
- DeltaMode - Supplies a boolean indicating whether or not the memory pool
- list represents a delta from a previous point in time.
- ActiveCountThreshold - Supplies the active count threshold. No statistics
- will be displayed for tags with an active count less than this
- threshold.
- Return Value:
- None.
- --*/
- PLIST_ENTRY
- DbgrSubtractMemoryStatistics (
- PLIST_ENTRY CurrentListHead,
- PLIST_ENTRY BaseListHead
- );
- /*++
- Routine Description:
- This routine subtracts the given current memory list from the base memory
- list, returning a list that contains the deltas for memory pool statistics.
- If this routine ever fails, it just returns the current list.
- Arguments:
- CurrentListHead - Supplies a pointer to the head of the current list of
- memory pool data.
- BaseListHead - supplies a pointer to the head of the base line memory list
- from which the deltas are created.
- Return Value:
- Returns a new memory pool list if possible. If the routine fails or there
- is no base line, then the current memory list is returned.
- --*/
- //
- // Functions implemented by the OS support layer.
- //
- BOOL
- DbgrOsInitializeConsole (
- PBOOL EchoCommands
- );
- /*++
- Routine Description:
- This routine performs any initialization steps necessary before the console
- can be used.
- Arguments:
- EchoCommands - Supplies a pointer where a boolean will be returned
- indicating if the debugger should echo commands received (TRUE) or if
- the console has already echoed the command (FALSE).
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- VOID
- DbgrOsDestroyConsole (
- VOID
- );
- /*++
- Routine Description:
- This routine cleans up anything related to console functionality as a
- debugger is exiting.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- INT
- DbgrOsCreateThread (
- PDBGR_THREAD_ROUTINE ThreadRoutine,
- PVOID Parameter
- );
- /*++
- Routine Description:
- This routine creates a new thread.
- Arguments:
- ThreadRoutine - Supplies a pointer to the routine to run in the new thread.
- The thread is destroyed when the supplied routine returns.
- Parameter - Supplies a pointer to a parameter to pass to the thread.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- int
- DbgrOsCreatePipe (
- int FileDescriptors[2]
- );
- /*++
- Routine Description:
- This routine creates an anonymous pipe.
- Arguments:
- FileDescriptors - Supplies a pointer where handles will be returned
- representing the read and write ends of the pipe.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- char *
- DbgrOsGetUserName (
- void
- );
- /*++
- Routine Description:
- This routine returns the user name of the current process.
- Arguments:
- None.
- Return Value:
- Returns a pointer to a string containing the user name if it can be found.
- The caller should not free or modify this memory, and it may be reused on
- subsequent calls.
- --*/
- char *
- DbgrOsGetHostName (
- void
- );
- /*++
- Routine Description:
- This routine returns the host name of the current machine.
- Arguments:
- None.
- Return Value:
- Returns a pointer to a string containing the user name if it can be found.
- The caller is responsible for freeing this memory.
- --*/
- VOID
- DbgrOsPrepareToReadInput (
- VOID
- );
- /*++
- Routine Description:
- This routine is called before the debugger begins to read a line of input
- from the user.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- BOOL
- DbgrOsGetCharacter (
- PUCHAR Key,
- PUCHAR ControlKey
- );
- /*++
- Routine Description:
- This routine gets one character from the standard input console.
- Arguments:
- Key - Supplies a pointer that receives the printable character. If this
- parameter is NULL, printing characters will be discarded from the input
- buffer.
- ControlKey - Supplies a pointer that receives the non-printable character.
- If this parameter is NULL, non-printing characters will be discarded
- from the input buffer.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- VOID
- DbgrOsRemoteInputAdded (
- VOID
- );
- /*++
- Routine Description:
- This routine is called after a remote command is received and placed on the
- standard input remote command list. It wakes up a thread blocked on local
- user input in an OS-dependent fashion.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- VOID
- DbgrOsPostInputCallback (
- VOID
- );
- /*++
- Routine Description:
- This routine is called after a line of input is read from the user, giving
- the OS specific code a chance to restore anything it did in the prepare
- to read input function.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- BOOL
- InitializeCommunications (
- PSTR Channel,
- ULONG Baudrate
- );
- /*++
- Routine Description:
- This routine initializes the communication medium the debugger uses to
- communicate with the target.
- Arguments:
- Channel - Supplies a description of the communication medium.
- Baudrate - Supplies the baudrate to use for serial based communications.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- VOID
- DestroyCommunications (
- VOID
- );
- /*++
- Routine Description:
- This routine tears down the debug communication channel.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- BOOL
- CommReceive (
- PVOID Buffer,
- ULONG BytesToRead
- );
- /*++
- Routine Description:
- This routine receives a number of bytes from the debugger/debuggee
- connection.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the data should be returned.
- BytesToRead - Supplies the number of bytes that should be received into the
- buffer.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- BOOL
- CommSend (
- PVOID Buffer,
- ULONG BytesToSend
- );
- /*++
- Routine Description:
- This routine sends a number of bytes through the debugger/debuggee
- connection.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the data to be sent resides.
- BytesToSend - Supplies the number of bytes that should be sent.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- ULONG
- CommReceiveBytesReady (
- VOID
- );
- /*++
- Routine Description:
- This routine determines how many bytes of data are ready to be read from
- the communication channel.
- Arguments:
- None.
- Return Value:
- Returns the number of bytes ready to be read.
- --*/
- VOID
- CommStall (
- ULONG Milliseconds
- );
- /*++
- Routine Description:
- This routine pauses for the given amount of time.
- Arguments:
- Milliseconds - Supplies the amount of time, in milliseconds, to stall the
- current thread for.
- Return Value:
- None.
- --*/
- BOOL
- UiLoadSourceFile (
- PSTR Path,
- PVOID Contents,
- ULONGLONG Size
- );
- /*++
- Routine Description:
- This routine loads the contents of a file into the source window.
- Arguments:
- Path - Supplies the path of the file being loaded. If this is NULL, then
- the source window should be cleared.
- Contents - Supplies the source file data. This can be NULL.
- Size - Supplies the size of the source file data in bytes.
- Return Value:
- Returns TRUE if there was no error, or FALSE if there was an error.
- --*/
- BOOL
- UiHighlightExecutingLine (
- LONG LineNumber,
- BOOL Enable
- );
- /*++
- Routine Description:
- This routine highlights the currently executing source line and scrolls to
- it.
- Arguments:
- LineNumber - Supplies the 1-based line number to highlight (ie the first
- line in the source file is line 1).
- Enable - Supplies a flag indicating whether to highlight this line (TRUE)
- or restore the line to its original color (FALSE).
- Return Value:
- Returns TRUE if there was no error, or FALSE if there was an error.
- --*/
- VOID
- UiEnableCommands (
- BOOL Enable
- );
- /*++
- Routine Description:
- This routine enables or disables the command edit control from being
- enabled. If disabled, the edit control will be made read only.
- Arguments:
- Enable - Supplies a flag indicating whether or not to enable (TRUE) or
- disable (FALSE) the command box.
- Return Value:
- None.
- --*/
- VOID
- UiSetCommandText (
- PSTR Text
- );
- /*++
- Routine Description:
- This routine sets the text inside the command edit box.
- Arguments:
- Text - Supplies a pointer to a null terminated string to set the command
- text to.
- Return Value:
- None.
- --*/
- VOID
- UiSetPromptText (
- PSTR Text
- );
- /*++
- Routine Description:
- This routine sets the text inside the prompt edit box.
- Arguments:
- Text - Supplies a pointer to a null terminated string to set the prompt
- text to.
- Return Value:
- None.
- --*/
- VOID
- UiDisplayProfilerData (
- PROFILER_DATA_TYPE DataType,
- PROFILER_DISPLAY_REQUEST DisplayRequest,
- ULONG Threshold
- );
- /*++
- Routine Description:
- This routine displays the profiler data collected by the core debugging
- infrastructure.
- Arguments:
- DataType - Supplies the type of profiler data that is to be displayed.
- DisplayRequest - Supplies a value requesting a display action, which can
- either be to display data once, continually, or to stop continually
- displaying data.
- Threshold - Supplies the minimum percentage a stack entry hit must be in
- order to be displayed.
- Return Value:
- None.
- --*/
- HANDLE
- CreateDebuggerLock (
- VOID
- );
- /*++
- Routine Description:
- This routine creates a debugger lock.
- Arguments:
- None.
- Return Value:
- Returns a handle to a debugger lock on success, or NULL on failure.
- --*/
- VOID
- AcquireDebuggerLock (
- HANDLE Lock
- );
- /*++
- Routine Description:
- This routine acquires a debugger lock. This routine does not return until
- the lock is required.
- Arguments:
- Lock - Supplies a handle to the lock that is to be acquired.
- Return Value:
- None.
- --*/
- VOID
- ReleaseDebuggerLock (
- HANDLE Lock
- );
- /*++
- Routine Description:
- This routine releases a debugger lock.
- Arguments:
- Lock - Supplies a handle to the lock that is to be released.
- Return Value:
- None.
- --*/
- VOID
- DestroyDebuggerLock (
- HANDLE Lock
- );
- /*++
- Routine Description:
- This routine destroys a debugger lock.
- Arguments:
- Lock - Supplies a handle to the lock that is to be destroyed.
- Return Value:
- None.
- --*/
|