12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795 |
- /*++
- Copyright (c) 2012 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- dbgrcomm.h
- Abstract:
- This header contains definitions for the debugger protocol communication
- helper routines.
- Author:
- Evan Green 3-Jul-2012
- --*/
- //
- // ---------------------------------------------------------------- Definitions
- //
- #define ARM_INSTRUCTION_LENGTH 4
- #define ARM_FUNCTION_PROLOGUE 0xE1A0C00D
- #define DEBUGGER_MAX_COMMAND_ARGUMENTS 32
- //
- // Define the maximum number of call stack elements that can be printed.
- //
- #define MAX_CALL_STACK 4096
- //
- // Define debugger flags.
- //
- //
- // This flag is set if the debugger is in the process of exiting the
- // application.
- //
- #define DEBUGGER_FLAG_EXITING 0x00000001
- //
- // This flag is set if the debugger should echo commands sent to standard in.
- //
- #define DEBUGGER_FLAG_ECHO_COMMANDS 0x00000002
- //
- // This flag is set to enable stepping by source line numbers, or cleared to
- // step by instruction.
- //
- #define DEBUGGER_FLAG_SOURCE_LINE_STEPPING 0x00000004
- //
- // This flag is set if the debugger should print source file and line numbers
- // along with each address symbol.
- //
- #define DEBUGGER_FLAG_PRINT_LINE_NUMBERS 0x00000008
- //
- // This flag is set if the user would like an initial break-in upon
- // connection.
- //
- #define DEBUGGER_FLAG_INITIAL_BREAK 0x00000010
- //
- // This flag is set if the user wants to print all attempted source file loads
- // (useful when trying to figure out why source display isn't working).
- //
- #define DEBUGGER_FLAG_PRINT_SOURCE_LOADS 0x00000020
- //
- // Define debugger target flags.
- //
- //
- // This flag is set if the target is running.
- //
- #define DEBUGGER_TARGET_RUNNING 0x00000001
- //
- // x86 Flags.
- //
- #define IA32_EFLAG_CF 0x00000001
- #define IA32_EFLAG_PF 0x00000004
- #define IA32_EFLAG_AF 0x00000010
- #define IA32_EFLAG_ZF 0x00000040
- #define IA32_EFLAG_SF 0x00000080
- #define IA32_EFLAG_TF 0x00000100
- #define IA32_EFLAG_IF 0x00000200
- #define IA32_EFLAG_DF 0x00000400
- #define IA32_EFLAG_OF 0x00000800
- #define IA32_EFLAG_IOPL_MASK 0x00003000
- #define IA32_EFLAG_IOPL_SHIFT 12
- #define IA32_EFLAG_NT 0x00004000
- #define IA32_EFLAG_RF 0x00010000
- #define IA32_EFLAG_VM 0x00020000
- #define IA32_EFLAG_AC 0x00040000
- #define IA32_EFLAG_VIF 0x00080000
- #define IA32_EFLAG_VIP 0x00100000
- #define IA32_EFLAG_ID 0x00200000
- #define IA32_EFLAG_ALWAYS_0 0xFFC08028
- #define IA32_EFLAG_ALWAYS_1 0x00000002
- //
- // ARM Processor modes.
- //
- #define ARM_MODE_USER 0x00000010
- #define ARM_MODE_FIQ 0x00000011
- #define ARM_MODE_IRQ 0x00000012
- #define ARM_MODE_SVC 0x00000013
- #define ARM_MODE_ABORT 0x00000017
- #define ARM_MODE_UNDEF 0x0000001B
- #define ARM_MODE_SYSTEM 0x0000001F
- #define ARM_MODE_MASK 0x0000001F
- //
- // ARM Program Status Register flags.
- //
- #define PSR_FLAG_NEGATIVE 0x80000000
- #define PSR_FLAG_ZERO 0x40000000
- #define PSR_FLAG_CARRY 0x20000000
- #define PSR_FLAG_OVERFLOW 0x10000000
- #define PSR_FLAG_SATURATION 0x08000000
- #define PSR_FLAG_JAZELLE 0x01000000
- #define PSR_FLAG_THUMB 0x00000020
- #define PSR_FLAG_IRQ 0x00000080
- #define PSR_FLAG_FIQ 0x00000040
- //
- // ARM Instruction information.
- //
- #define ARM_BREAK_INSTRUCTION 0xE7F000F3
- #define ARM_BREAK_INSTRUCTION_LENGTH ARM_INSTRUCTION_LENGTH
- #define THUMB_BREAK_INSTRUCTION 0xDE20
- #define THUMB_BREAK_INSTRUCTION_LENGTH 2
- #define ARM_THUMB_BIT 0x00000001
- #define X86_BREAK_INSTRUCTION 0xCC
- #define X86_BREAK_INSTRUCTION_LENGTH 1
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- typedef enum _DEBUGGER_BREAK_POINT_TYPE {
- BreakpointTypeInvalid,
- BreakpointTypeExecution,
- BreakpointTypeRead,
- BreakpointTypeWrite,
- BreakpointTypeReadWrite
- } DEBUGGER_BREAK_POINT_TYPE, *PDEBUGGER_BREAK_POINT_TYPE;
- /*++
- Structure Description:
- This structure defines a breakpoint.
- Members:
- ListEntry - Stores pointers to the next and previous breakpoints in the
- global list of breakpoints.
- Index - Stores the index of the breakpoint.
- Type - Stores the type of breakpoint, whether it be software or some sort of
- hardware breakpoint.
- Address - Stores the virtual address of the breakpoint.
- AccessSize - Stores the access size of the breakpoint if it is a break on
- access type of breakpoint.
- OriginalValue - Stores the original contents of the instruction stream
- before the breakpoint was inserted. This only applies to software
- execution breakpoints.
- Enabled - Stores a flag indicating whether or not this breakpoint is
- currently active in the system.
- --*/
- typedef struct _DEBUGGER_BREAK_POINT {
- LIST_ENTRY ListEntry;
- LONG Index;
- DEBUGGER_BREAK_POINT_TYPE Type;
- ULONGLONG Address;
- UCHAR AccessSize;
- ULONG OriginalValue;
- BOOL Enabled;
- } DEBUGGER_BREAK_POINT, *PDEBUGGER_BREAK_POINT;
- /*++
- Structure Description:
- This structure defines parameters for dumping memory.
- Members:
- Virtual - Stores a boolean indicating if the address is virtual (TRUE) or
- physical (FALSE).
- PrintCharacters - Stores a boolean indicating if characters should be
- printed as well.
- NextAddress - Stores the next address to dump.
- Columns - Stores the desired number of columns.
- TotalValues - Stores the desired total number of values to dump.
- --*/
- typedef struct _DEBUGGER_DUMP_MEMORY_PARAMETERS {
- BOOL Virtual;
- BOOL PrintCharacters;
- ULONGLONG NextAddress;
- ULONG Columns;
- ULONG TotalValues;
- } DEBUGGER_DUMP_MEMORY_PARAMETERS, *PDEBUGGER_DUMP_MEMORY_PARAMETERS;
- /*++
- Structure Description:
- This structure defines a mutable array of pointer sized elements.
- Members:
- Elements - Stores the array of pointers.
- Size - Stores the number of valid elements in the array.
- Capacity - Storse the maximum number of elements that can be put in the
- array before the array itself needs to be reallocated.
- --*/
- typedef struct _POINTER_ARRAY {
- PVOID *Elements;
- ULONGLONG Size;
- ULONGLONG Capacity;
- } POINTER_ARRAY, *PPOINTER_ARRAY;
- /*++
- Structure Description:
- This structure defines thread profiling parameters.
- Members:
- StatisticsListHead - Stores the head of the list of thread statistics data.
- StatisticsListLock - Stores a handle to the lock serializing access to the
- thread statistics list.
- StatisticsLock - Stores a handle to the lock serializing access to the
- pointer arrays and other thread profiling data.
- ContextSwaps - Stores the array of context swap data.
- Processes - Stores the array of process data.
- Threads - Stores the array of thread data.
- ProcessorCount - Stores the number of processors in the system.
- ReferenceTime - Stores the reference time for thread profiling data.
- ProcessNameWidth - Stores the width in characters of the process name field.
- ThreadNameWidth - Stores the width in characters of the thread name field.
- --*/
- typedef struct _DEBUGGER_THREAD_PROFILING_DATA {
- LIST_ENTRY StatisticsListHead;
- HANDLE StatisticsListLock;
- HANDLE StatisticsLock;
- PPOINTER_ARRAY ContextSwaps;
- PPOINTER_ARRAY Processes;
- PPOINTER_ARRAY Threads;
- ULONG ProcessorCount;
- PROFILER_THREAD_TIME_COUNTER ReferenceTime;
- ULONG ProcessNameWidth;
- ULONG ThreadNameWidth;
- } DEBUGGER_THREAD_PROFILING_DATA, *PDEBUGGER_THREAD_PROFILING_DATA;
- /*++
- Structure Description:
- This structure stores profiling information.
- Members:
- StackListHead - Stores the head of the list of stack sampling data.
- StackListLock - Stores a handle to the lock serializing access to the stack
- list.
- MemoryListHead - Stores the head of the list of memory profiling data.
- MemoryListLock - Stores a handle to the lock serializing access to the
- memory list.
- MemoryCollectionActive - Stores a boolean indicating if memory data is
- being collected.
- CommandLineStackRoot - Stores the stack profiling root node when running
- from the command line.
- CommandLinePoolListHead - Stores a pointer to the most recent pool when
- running command line commands.
- CommandLineBaseListHead - Stores a pointer to the base line memory list
- list when running command line commands.
- --*/
- typedef struct _DEBUGGER_PROFILING_DATA {
- LIST_ENTRY StackListHead;
- HANDLE StackListLock;
- LIST_ENTRY MemoryListHead;
- HANDLE MemoryListLock;
- BOOL MemoryCollectionActive;
- PSTACK_DATA_ENTRY CommandLineStackRoot;
- PLIST_ENTRY CommandLinePoolListHead;
- PLIST_ENTRY CommandLineBaseListHead;
- } DEBUGGER_PROFILING_DATA, *PDEBUGGER_PROFILING_DATA;
- /*++
- Structure Description:
- This structure stores information pertaining to the maintenance of standard
- output.
- Members:
- Lock - Stores the handle to the lock synchronizing access to the console
- buffer.
- ConsoleBuffer - Stores a pointer to the console buffer.
- ConsoleBufferSize - Stores the number of valid bytes in the console
- buffer, including the null terminator if there is one.
- ConsoleBufferCapacity - Stores the allocation size of the console buffer.
- Prompt - Stores the current prompt.
- --*/
- typedef struct _DEBUGGER_STANDARD_OUT {
- HANDLE Lock;
- PCHAR ConsoleBuffer;
- ULONGLONG ConsoleBufferSize;
- ULONGLONG ConsoleBufferCapacity;
- PSTR Prompt;
- } DEBUGGER_STANDARD_OUT, *PDEBUGGER_STANDARD_OUT;
- /*++
- Structure Description:
- This structure stores information pertaining to the maintenance of standard
- input.
- Members:
- Lock - Stores a lock serializing access to the remote command list.
- RemoteCommandList - Stores the head of the list of remote commands waiting
- to be executed.
- --*/
- typedef struct _DEBUGGER_STANDARD_IN {
- HANDLE Lock;
- LIST_ENTRY RemoteCommandList;
- } DEBUGGER_STANDARD_IN, *PDEBUGGER_STANDARD_IN;
- /*++
- Structure Description:
- This structure stores information pertaining to managing a remote debug
- server.
- Members:
- Socket - Stores the socket listening to incoming connections.
- Host - Stores the host name or IP the server is listening on.
- Port - Stores the port the server is listening on.
- ShutDown - Stores a value indicating that the server should be shut down.
- ClientList - Stores the list of connected clients.
- --*/
- typedef struct _DEBUGGER_SERVER_CONTEXT {
- int Socket;
- char *Host;
- int Port;
- volatile int ShutDown;
- LIST_ENTRY ClientList;
- } DEBUGGER_SERVER_CONTEXT, *PDEBUGGER_SERVER_CONTEXT;
- /*++
- Structure Description:
- This structure stores information about the remote connection of the client
- (this application) to a remote server.
- Members:
- Socket - Stores the socket connected to the server.
- ShutDown - Stores a value indicating that the client network thread is
- finished.
- --*/
- typedef struct _DEBUGGER_CLIENT_CONTEXT {
- volatile int ShutDown;
- int Socket;
- } DEBUGGER_CLIENT_CONTEXT, *PDEBUGGER_CLIENT_CONTEXT;
- /*++
- Structure Description:
- This structure stores information about the current source line.
- Members:
- Path - Stores the full path to the source file, as represented in the
- debug symbols. This needs to be freed.
- ActualPath - Stores the full path to the source file where it was actually
- found. This needs to be freed.
- Contents - Stores the contents of the source file. This needs to be freed.
- Size - Stores the size of the file in bytes.
- LineNumber - Stores the currently highlighted line number, or 0 if no line
- is highlighted.
- --*/
- typedef struct _DEBUGGER_SOURCE_FILE {
- PSTR Path;
- PSTR ActualPath;
- PVOID Contents;
- ULONGLONG Size;
- ULONGLONG LineNumber;
- } DEBUGGER_SOURCE_FILE, *PDEBUGGER_SOURCE_FILE;
- /*++
- Structure Description:
- This structure stores information about the current source line.
- Members:
- ListEntry - Stores pointers to the next and previous source paths.
- Prefix - Stores a pointer to the prefix to pull off of the potential
- source path. If the source in question does not match, it will be
- skipped. An empty prefix matches everything.
- PrefixLength - Stores the length of the prefix in characters, not including
- the null terminator.
- Path - Stores a pointer to the path to search for sources in.
- PathLength - Stores the length of the path string in characters, not
- including the null terminator.
- --*/
- typedef struct _DEBUGGER_SOURCE_PATH {
- LIST_ENTRY ListEntry;
- PSTR Prefix;
- UINTN PrefixLength;
- PSTR Path;
- UINTN PathLength;
- } DEBUGGER_SOURCE_PATH, *PDEBUGGER_SOURCE_PATH;
- /*++
- Structure Description:
- This structure defines an instance of the debugger application.
- Members:
- Flags - Stores a bitfield of global flags, see DEBUGGER_FLAG_* for
- definitions.
- TargetFlags - Stores a bitfield of flags regarding the target connection.
- See DEBUGGER_TARGET_* definitions.
- SymbolPath - Stores a pointer to an array of strings containing the symbol
- path to search when trying to load symbols.
- SymbolPathCount - Stores the number of elements in the symbol path array.
- RangeStepValid - Stores a boolean indicating whether the range step
- parameters are active.
- RangeStepParameters - Stores the parameters for the current range step.
- OneTimeBreakValid - Stores a boolean indicating if the one-time breakpoint
- (used for "g <addr>") is valid.
- OneTimeBreakAddress - Stores the target memory address of the one-time
- breakpoint.
- OneTimeBreakOriginalValue - Stores the original value at the one-time
- break address.
- LastMemoryDump - Stores the parameters used in the most recent memory
- dump.
- BreakpointList - Stores the head of the list of breakpoints.
- BreakpointToRestore - Stores a pointer to the breakpoint to reset after
- stepping off of it.
- PreviousProcess - Stores the process ID of the last debugger event, used to
- determine if the symbol list should be reloaded.
- BreakInstructionLength - Stores the length of the instruction of the most
- recent break.
- DisassemblyAddress - Stores the address of the next disassembly command if
- no address is provided.
- LoadedExtensions - Stores the list head of loaded debugger extensions.
- SourceFile - Stores information about the currently displayed source file.
- SourcePathList - Stores the head of the list of DEBUGGER_SOURCE_PATHs.
- ModuleList - Stores the loaded module list.
- RemoteModuleListSignature - Stores the most recent loaded module list
- signature.
- MachineType - Stores the target machine type.
- ThreadProfiling - Stores the thread profiling data.
- ProfilingData - Stores generic profiling data.
- StandardOut - Stores the standard out information.
- StandardIn - Stores the standard in information.
- CommandBuffer - Stores the buffer that holds the currently running debugger
- command.
- CommandBufferSize - Stores the total size of the command buffer in bytes.
- CommandHistory - Stores the debugger command history array.
- CommandHistorySize - Stores the size of the command history array. Not all
- of these elements are necessarily valid.
- CommandHistoryNextIndex - Stores the index where the next history entry
- will be deposited.
- Server - Stores context when this debugger is acting as a remote server.
- Client - Stores context when this debugger is acting as a remote client.
- CurrentEvent - Stores the current debug event.
- ConnectionType - Stores the current debug connection type.
- FrameRegisters - Stores the registers as unwound to the currently displayed
- stack frame.
- CurrentFrame - Stores the current stack frame index.
- --*/
- struct _DEBUGGER_CONTEXT {
- ULONG Flags;
- ULONG TargetFlags;
- PSTR *SymbolPath;
- ULONG SymbolPathCount;
- BOOL RangeStepValid;
- RANGE_STEP RangeStepParameters;
- BOOL OneTimeBreakValid;
- ULONGLONG OneTimeBreakAddress;
- ULONG OneTimeBreakOriginalValue;
- DEBUGGER_DUMP_MEMORY_PARAMETERS LastMemoryDump;
- LIST_ENTRY BreakpointList;
- PDEBUGGER_BREAK_POINT BreakpointToRestore;
- ULONG PreviousProcess;
- ULONG BreakInstructionLength;
- ULONGLONG DisassemblyAddress;
- LIST_ENTRY LoadedExtensions;
- DEBUGGER_SOURCE_FILE SourceFile;
- LIST_ENTRY SourcePathList;
- ULONG HighlightedLineNumber;
- DEBUGGER_MODULE_LIST ModuleList;
- ULONGLONG RemoteModuleListSignature;
- ULONG MachineType;
- DEBUGGER_THREAD_PROFILING_DATA ThreadProfiling;
- DEBUGGER_PROFILING_DATA ProfilingData;
- DEBUGGER_STANDARD_OUT StandardOut;
- DEBUGGER_STANDARD_IN StandardIn;
- PSTR CommandBuffer;
- ULONG CommandBufferSize;
- PSTR *CommandHistory;
- ULONG CommandHistorySize;
- ULONG CommandHistoryNextIndex;
- DEBUGGER_SERVER_CONTEXT Server;
- DEBUGGER_CLIENT_CONTEXT Client;
- DEBUGGER_EVENT CurrentEvent;
- DEBUG_CONNECTION_TYPE ConnectionType;
- REGISTERS_UNION FrameRegisters;
- ULONG CurrentFrame;
- };
- typedef
- INT
- (*PDEBUGGER_COMMAND_ROUTINE) (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine implements a registered debugger command.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- /*++
- Structure Description:
- This structure defines a debugger command registration entry.
- Members:
- Command - Stores a pointer to a string containing the name of the command
- to register.
- CommandRoutine - Stores a pointer to the routine to execute when this
- command is invoked.
- HelpText - Stores a pointer to a one-liner string describing what the
- command does.
- --*/
- typedef struct _DEBUGGER_COMMAND_ENTRY {
- PSTR Command;
- PDEBUGGER_COMMAND_ROUTINE CommandRoutine;
- PSTR HelpText;
- } DEBUGGER_COMMAND_ENTRY, *PDEBUGGER_COMMAND_ENTRY;
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // ------------------------------------------------------------------ Functions
- //
- BOOL
- DbgrGetCommand (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine retrieves a command from the user or a remote client.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- VOID
- DbgrpSetPromptText (
- PDEBUGGER_CONTEXT Context,
- PSTR Prompt
- );
- /*++
- Routine Description:
- This routine sets the command prompt to the given string.
- Arguments:
- Context - Supplies a pointer to the application context.
- Prompt - Supplies a pointer to the null terminated string containing the
- prompt to set.
- Return Value:
- None.
- --*/
- BOOL
- DbgrpSplitCommandArguments (
- PSTR Input,
- PSTR Arguments[DEBUGGER_MAX_COMMAND_ARGUMENTS],
- PULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine splits a command line into its arguments.
- Arguments:
- Input - Supplies a pointer to the input command line buffer.
- Arguments - Supplies a pointer to an array of strings that will receive any
- additional arguments.
- ArgumentCount - Supplies a pointer where the count of arguments will be
- returned.
- Return Value:
- Returns TRUE on success, FALSE on failure.
- --*/
- //
- // Profiling functions
- //
- INT
- DbgrProfilerInitialize (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine initializes the debugger for profiler data consumption.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- VOID
- DbgrProfilerDestroy (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine destroys any structures used to consume profiler data.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- None.
- --*/
- INT
- DbgrDispatchProfilerCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine handles a profiler command.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments.
- ArgumentCount - Supplies the number of arguments in the Arguments array.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- VOID
- DbgrProcessProfilerNotification (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine processes a profiler notification that the debuggee sends to
- the debugger. The routine should collect the profiler data and return as
- quickly as possible.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- None.
- --*/
- //
- // General debugger functions
- //
- PDEBUGGER_COMMAND_ENTRY
- DbgrLookupCommand (
- PSTR Command
- );
- /*++
- Routine Description:
- This routine attempts to find a debugger command entry.
- Arguments:
- Command - Supplies a pointer to the null-terminated string containing the
- name of the command that was invoked. This command is split on the
- period character, and the first segment is looked up.
- Return Value:
- Returns a pointer to the command entry on success.
- NULL if there no such command, or on failure.
- --*/
- INT
- DbgrInitialize (
- PDEBUGGER_CONTEXT Context,
- DEBUG_CONNECTION_TYPE ConnectionType
- );
- /*++
- Routine Description:
- This routine initializes data structures for common debugger functionality.
- Arguments:
- Context - Supplies a pointer to the application context.
- ConnectionType - Supplies the type of debug connection to set the debugger
- up in.
- Return Value:
- 0 on success.
- Returns an error number on failure.
- --*/
- VOID
- DbgrDestroy (
- PDEBUGGER_CONTEXT Context,
- DEBUG_CONNECTION_TYPE ConnectionType
- );
- /*++
- Routine Description:
- This routine destroys any data structures used for common debugger
- functionality.
- Arguments:
- Context - Supplies a pointer to the application context.
- ConnectionType - Supplies the type of debug connection the debugger was set
- up in.
- Return Value:
- None.
- --*/
- INT
- DbgrConnect (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine establishes a link with the target debuggee. It is assumed that
- the underlying communication layer has already been established (COM ports
- have been opened and initialized, etc).
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrQuit (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine exits the local debugger.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrGo (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine interprets the "go" command from the user.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSingleStep (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine steps the target by a single instruction.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrGetSetRegisters (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints or modifies the target machine's registers.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrGetSetSpecialRegisters (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints or modifies the target machine's special registers.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrPrintCallStack (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints the current call stack.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetFrame (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine changes the current stack frame, so that local variables may
- come from a different function in the call stack.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDisassemble (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine disassembles instructions from the target.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrWaitForEvent (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine gets an event from the target, such as a break event or other
- exception.
- Arguments:
- Context - Supplies a pointer to the debugger context.
- Return Value:
- 0 on success,
- Returns an error code on failure.
- --*/
- INT
- DbgrSearchSymbols (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine searches for symbols. Wildcards are accepted. If the search
- string is preceded by "modulename!" then only that module will be searched.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDumpTypeCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints information about a type description or value. If only
- a type is specified, the type format will be printed. If an address is
- passed as a second parameter, then the values will be dumped. If a global
- or local variable is passed as the first parameter, the values will also be
- dumped.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDumpMemory (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints the contents of debuggee memory to the screen.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDumpList (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine interates over a linked list and prints out the structure
- information for each entry. It also performs basic validation on the list,
- checking for bad previous pointers.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrEditMemory (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine writes to the target memory space.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrEvaluate (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine evaluates a numerical expression and prints it out in both
- decimal and hexadecimal.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrShowSourceAtAddressCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine shows the source file for the provided address and highlights
- the specific line associated with the address.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrPrintLocals (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints the values of the local variables inside the currently
- selected stack frame.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- VOID
- DbgrUnhighlightCurrentLine (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine restores the currently executing line to the normal background
- color in the source window.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- None.
- --*/
- INT
- DbgrListBreakPoints (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine lists all valid breakpoints in the target.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrEnableBreakPoint (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine lists all valid breakpoints in the target.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDeleteBreakPoint (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine deletes a breakpoint from the target.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrCreateBreakPoint (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine creates a new breakpoint in the debuggee.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrStep (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine performs a source or assembly line step in the debugger.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetSourceStepping (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine turns source line stepping on or off.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetSourceLinePrinting (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine turns on or off the option to print the source file and line
- next to every text address.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrReturnToCaller (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine interprets the "go" command from the user.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetSymbolPathCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine sets or updates the symbol search path.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetSourcePathCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine sets or updates the source search path.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrReloadSymbols (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine unloads and reloads all symbols from the search path.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSetSymbolPath (
- PDEBUGGER_CONTEXT Context,
- PSTR Path,
- BOOL Append
- );
- /*++
- Routine Description:
- This routine sets or updates the symbol search path.
- Arguments:
- Context - Supplies a pointer to the application context.
- Path - Supplies a pointer to the new symbol path. This could contain
- multiple symbol paths if separated by semicolons.
- Append - Supplies a boolean indicating whether the new path should replace
- or append the existing path.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrLoadExtension (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine loads or unloads a debugger extension.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrSwitchProcessor (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine switches the debugger to another processor in kernel mode or
- thread in user mode.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrPrintProcessorBlock (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine prints the contents of the current processor block.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrDumpPointerSymbols (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine dumps memory at the provided address and attempts to match
- symbols at the dumped memory addresses.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrProfileCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine handles the profile command. It essentially just forwards on
- to the profile handler.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrRebootCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine handles the profile command. It essentially just forwards on
- to the profile handler.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrServerCommand (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount
- );
- /*++
- Routine Description:
- This routine starts or stops a remote server interface.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies an array of strings containing the arguments. The
- first argument is the command itself.
- ArgumentCount - Supplies the count of arguments. This is always at least
- one.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrContinue (
- PDEBUGGER_CONTEXT Context,
- BOOL SetOneTimeBreak,
- ULONGLONG Address
- );
- /*++
- Routine Description:
- This routine sends the "go" command to the target, signaling to continue
- execution.
- Arguments:
- Context - Supplies a pointer to the application context.
- SetOneTimeBreak - Supplies a flag indicating whether to go unconditionally
- (FALSE) or with a one-time breakpoint (TRUE).
- Address - Supplies the address of the one-time breakpoint if one was
- specified.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- VOID
- DbgrShowSourceAtAddress (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address
- );
- /*++
- Routine Description:
- This routine loads the source file and highlights the source line
- corresponding to the given target address.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the target's executing virtual address.
- Return Value:
- None.
- --*/
- INT
- DbgrDumpType (
- PDEBUGGER_CONTEXT Context,
- PSTR *Arguments,
- ULONG ArgumentCount,
- PVOID RawDataStream,
- ULONG RawDataStreamSizeInBytes
- );
- /*++
- Routine Description:
- This routine prints information about a type description or value. If only
- a type is specified, the type format will be printed. If an address is
- passed as a second parameter, then the values will be dumped. If a global
- or local variable is passed as the first parameter, the values will also be
- dumped.
- Arguments:
- Context - Supplies a pointer to the application context.
- Arguments - Supplies a pointer to an array of argument strings.
- ArgumentCount - Supplies the number of arguments in the argument array.
- RawDataStream - Supplies the actual memory to dump in the given type form.
- If this parameter is non-NULL, then the AddressString parameter is
- ignored. The size of this buffer must be non-zero.
- RawDataStreamSizeInBytes - Supplies the size of the raw data stream buffer,
- in bytes.
- Return Value:
- 0 if the information was printed successfully.
- Returns an error code on failure.
- --*/
- INT
- DbgrpHighlightExecutingLine (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG LineNumber
- );
- /*++
- Routine Description:
- This routine highlights the currently executing source line and scrolls to
- it, or removes the highlight.
- Arguments:
- Context - Supplies the application context.
- LineNumber - Supplies the one-based line number to highlight, or 0 to
- disable highlighting.
- Return Value:
- 0 on success.
- Non-zero on failure.
- --*/
- INT
- DbgrpLoadSourceFile (
- PDEBUGGER_CONTEXT Context,
- PSTR Path,
- PSTR *FoundPath,
- PVOID *Contents,
- PULONGLONG Size
- );
- /*++
- Routine Description:
- This routine loads a source file into memory.
- Arguments:
- Context - Supplies a pointer to the application context.
- Path - Supplies a pointer to the path to load.
- FoundPath - Supplies a pointer where a pointer to the path of the actual
- file loaded will be returned. The path may be modified by the source
- path list, so this represents the final found path.
- Contents - Supplies a pointer where a pointer to the loaded file will be
- returned on success. The caller is responsible for freeing this memory.
- Size - Supplies a pointer where the size of the file will be returned on
- success.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- INT
- DbgrpAddSourcePath (
- PDEBUGGER_CONTEXT Context,
- PSTR PathString
- );
- /*++
- Routine Description:
- This routine adds a source path entry to the given application context.
- Arguments:
- Context - Supplies a pointer to the application context.
- PathString - Supplies a pointer to the path string, which takes the form
- prefix=path. If there is no equals sign, then the prefix is assumed to
- be empty.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- VOID
- DbgrpDestroyAllSourcePaths (
- PDEBUGGER_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine destroys all source path entries in the given application
- context.
- Arguments:
- Context - Supplies a pointer to the application context.
- Return Value:
- 0 on success.
- Returns an error code on failure.
- --*/
- PSTR
- DbgGetAddressSymbol (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- PFUNCTION_SYMBOL *Function
- );
- /*++
- Routine Description:
- This routine gets a descriptive string version of the given address,
- including the module and function name if possible. It is the caller's
- responsibility to free the returned string.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the virtual address of the target to get information
- about.
- Function - Supplies an optional pointer where the function symbol will be
- returned if this turned out to be a function.
- Return Value:
- Returns a null-terminated string if successfull, or NULL on failure.
- --*/
- BOOL
- DbgGetDataSymbolTypeInformation (
- PDATA_SYMBOL DataSymbol,
- PTYPE_SYMBOL *TypeSymbol,
- PUINTN TypeSize
- );
- /*++
- Routine Description:
- This routine computes the type and type size of the given data symbol.
- Arguments:
- DataSymbol - Supplies a pointer to the data symbol whose type and type size
- are to be calculated.
- TypeSymbol - Supplies a pointer that receives a pointer to the type symbol
- that corresponds to the given data symbol.
- TypeSize - Supplies a pointer that receives the type size of the given
- data symbol.
- Return Value:
- Returns TRUE on success, or FALSE on failure.
- --*/
- INT
- DbgGetDataSymbolAddress (
- PDEBUGGER_CONTEXT Context,
- PDEBUG_SYMBOLS Symbols,
- PDATA_SYMBOL DataSymbol,
- ULONGLONG DebasedPc,
- PULONGLONG Address
- );
- /*++
- Routine Description:
- This routine returns the memory address of the given data symbol.
- Arguments:
- Context - Supplies a pointer to the application context.
- Symbols - Supplies a pointer to the module symbols.
- DataSymbol - Supplies a pointer to the data symbol whose address is to be
- returned.
- DebasedPc - Supplies the program counter value, assuming the image were
- loaded at its preferred base address (that is, actual PC minus the
- loaded base difference of the module).
- Address - Supplies a pointer where the debased memory address of the symbol
- will be returned. That is, the caller needs to add any loaded base
- difference of the module to this value.
- Return Value:
- 0 on success.
- ENOENT if the data symbol is not currently valid.
- ERANGE if the data symbol is not stored in memory.
- Other error codes on other failures.
- --*/
- INT
- DbgGetDataSymbolData (
- PDEBUGGER_CONTEXT Context,
- PDEBUG_SYMBOLS Symbols,
- PDATA_SYMBOL DataSymbol,
- ULONGLONG DebasedPc,
- PVOID DataStream,
- ULONG DataStreamSize,
- PSTR Location,
- ULONG LocationSize
- );
- /*++
- Routine Description:
- This routine returns the data contained by the given data symbol.
- Arguments:
- Context - Supplies a pointer to the application context.
- Symbols - Supplies a pointer to the module symbols.
- DataSymbol - Supplies a pointer to the data symbol whose data is to be
- retrieved.
- DebasedPc - Supplies the program counter value, assuming the image were
- loaded at its preferred base address (that is, actual PC minus the
- loaded base difference of the module).
- DataStream - Supplies a pointer that receives the data from the data symbol.
- DataStreamSize - Supplies the size of the data stream buffer.
- Location - Supplies an optional pointer where a string describing the
- location of the data symbol will be returned on success.
- LocationSize - Supplies the size of the location in bytes.
- Return Value:
- 0 on success.
- ENOENT if the data symbol is not currently active given the current state
- of the machine.
- Returns an error code on failure.
- --*/
- INT
- DbgPrintDataSymbol (
- PDEBUGGER_CONTEXT Context,
- PDEBUG_SYMBOLS Symbols,
- PDATA_SYMBOL DataSymbol,
- ULONGLONG DebasedPc,
- ULONG SpaceLevel,
- ULONG RecursionDepth
- );
- /*++
- Routine Description:
- This routine prints the location and value of a data symbol.
- Arguments:
- Context - Supplies a pointer to the application context.
- Symbols - Supplies a pointer to the module symbols.
- DataSymbol - Supplies a pointer to the data symbol to print.
- DebasedPc - Supplies the program counter value, assuming the image were
- loaded at its preferred base address (that is, actual PC minus the
- loaded base difference of the module).
- SpaceLevel - Supplies the number of spaces to print after every newline.
- Used for nesting types.
- RecursionDepth - Supplies how many times this should recurse on structure
- members. If 0, only the name of the type is printed.
- Return Value:
- 0 on success.
- ENOENT if the data symbol is not currently active given the current state
- of the machine.
- Returns an error code on failure.
- --*/
- INT
- DbgGetRegister (
- PDEBUGGER_CONTEXT Context,
- PREGISTERS_UNION Registers,
- ULONG RegisterNumber,
- PULONGLONG RegisterValue
- );
- /*++
- Routine Description:
- This routine returns the contents of a register given a debug symbol
- register index.
- Arguments:
- Context - Supplies a pointer to the application context.
- Registers - Supplies a pointer to the current machine context.
- RegisterNumber - Supplies the register index to get.
- RegisterValue - Supplies a pointer where the register value will be
- returned on success.
- Return Value:
- 0 on success.
- EINVAL if the register number is invalid.
- Other error codes on other failures.
- --*/
- INT
- DbgSetRegister (
- PDEBUGGER_CONTEXT Context,
- PREGISTERS_UNION Registers,
- ULONG RegisterNumber,
- ULONGLONG Value
- );
- /*++
- Routine Description:
- This routine sets the contents of a register given its register number.
- Arguments:
- Context - Supplies a pointer to the application context.
- Registers - Supplies a pointer to the current machine context. The register
- value will be set in this context.
- RegisterNumber - Supplies the register index to set.
- Value - Supplies the new value to set.
- Return Value:
- 0 on success.
- EINVAL if the register number is invalid.
- Other error codes on other failures.
- --*/
- INT
- DbgPrintTypeByName (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- PSTR TypeName,
- ULONG SpaceLevel,
- ULONG RecursionCount
- );
- /*++
- Routine Description:
- This routine prints a structure or value at a specified address, whose type
- is specified by a string.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies a target address pointer where the data resides.
- TypeName - Supplies a pointer to a string containing the type name to get.
- This should start with a type name, and can use dot '.' notation to
- specify field members, and array[] notation to specify dereferences.
- SpaceLevel - Supplies the number of spaces worth of indentation to print
- for subsequent lines.
- RecursionCount - Supplies the number of substructures to recurse into.
- Return Value:
- 0 on success.
- Returns an error number on failure.
- --*/
- INT
- DbgPrintType (
- PDEBUGGER_CONTEXT Context,
- PTYPE_SYMBOL Type,
- PVOID Data,
- UINTN DataSize,
- ULONG SpaceLevel,
- ULONG RecursionCount
- );
- /*++
- Routine Description:
- This routine prints the given type to the debugger console.
- Arguments:
- Context - Supplies a pointer to the application context.
- Type - Supplies a pointer to the data type to print.
- Data - Supplies a pointer to the data contents.
- DataSize - Supplies the size of the data buffer in bytes.
- SpaceLevel - Supplies the number of spaces worth of indentation to print
- for subsequent lines.
- RecursionCount - Supplies the number of substructures to recurse into.
- Return Value:
- 0 on success.
- Returns an error number on failure.
- --*/
- VOID
- DbgPrintStringData (
- PSTR String,
- UINTN Size,
- ULONG SpaceDepth
- );
- /*++
- Routine Description:
- This routine prints string data to the debugger console.
- Arguments:
- String - Supplies a pointer to the string data.
- Size - Supplies the number of bytes to print out.
- SpaceDepth - Supplies the indentation to use when breaking up a string into
- multiple lines.
- Return Value:
- None.
- --*/
- BOOL
- EvalGetRegister (
- PDEBUGGER_CONTEXT Context,
- PCSTR Register,
- PULONGLONG Value
- );
- /*++
- Routine Description:
- This routine gets the value of a register by name.
- Arguments:
- Context - Supplies a pointer to the application context.
- Register - Supplies the name of the register to get.
- Value - Supplies a pointer where the value of the register will be returned.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- BOOL
- EvalSetRegister (
- PDEBUGGER_CONTEXT Context,
- PCSTR Register,
- ULONGLONG Value
- );
- /*++
- Routine Description:
- This routine sets the value of a register by name.
- Arguments:
- Context - Supplies a pointer to the application context.
- Register - Supplies the name of the register to get.
- Value - Supplies the value to set in the register.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
|