2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
4 * This software may be freely used, copied, modified, and distributed
5 * provided that the above copyright notice is preserved in all copies of the
10 * ARM symbolic debugger toolbox interface
18 /* Minor points of uncertainty are indicated by a question mark in the
21 Wherever an interface is required to iterate over things of some class,
22 I prefer something of the form EnumerateXXs(..., XXProc *p, void *arg)
23 which results in a call of p(xx, arg) for each xx, rather than something
25 for (xxh = StartIterationOverXXs(); (xx = Next(xxh)) != 0; ) { ... }
26 EndIterationOverXXs(xxh);
28 (Each XXProc returns an Error value: if this is not Err_OK, iteration
29 stops immediately and the EnumerateXXs function returns that value).
31 ptrace has been retired as of insufficient utility. If such fuctionality is
32 required, it can be constructed using breakpoints.
34 The file form of all name fields in debug areas is in-line, with a length
35 byte and no terminator. The debugger toolbox makes an in-store translation,
36 where the strings are out of line (the namep variant in asdfmt.h) and have a
37 terminating zero byte: the pointer is to the first character of the string
38 with the length byte at ...->n.namep[-1].
49 typedef unsigned32 ARMaddress;
50 typedef unsigned32 ARMword;
51 typedef unsigned16 ARMhword;
61 typedef unsigned char Dbg_Byte;
63 typedef int Dbg_Error;
65 typedef struct Dbg_MCState Dbg_MCState;
66 /* A representation of the state of the target. The structure is not revealed.
67 A pointer to one of these is returned by Dbg_Initialise(), is passed to all
68 toolbox calls which refer to the state of the target, and is discarded
70 Nothing in the toolbox itself precludes there being multiple targets, each
74 /* Most toolbox interfaces return an error status. Only a few of the status
75 values are expected to be interesting to clients and defined here; the
76 rest are private (but a textual form can be produced by ErrorToChars()).
81 /* Partitioning of the error code space: errors below Dbg_Error_Base are RDI
82 errors (as defined in dbg_rdi.h). Codes above Dbg_Error_Limit are
83 available to clients, who may impose some further structure.
85 #define Dbg_Error_Base 0x1000
86 #define Dbg_Error_Limit 0x2000
88 #define DbgError(n) ((Dbg_Error)(Dbg_Error_Base+(n)))
90 #define Dbg_Err_OK Error_OK
91 #define Dbg_Err_Interrupted DbgError(1)
92 #define Dbg_Err_Overflow DbgError(2)
93 #define Dbg_Err_FileNotFound DbgError(3)
94 #define Dbg_Err_ActivationNotPresent DbgError(4)
95 #define Dbg_Err_OutOfHeap DbgError(5)
96 #define Dbg_Err_TypeNotSimple DbgError(6)
97 #define Dbg_Err_BufferFull DbgError(7)
98 #define Dbg_Err_AtStackBase DbgError(8)
99 #define Dbg_Err_AtStackTop DbgError(9)
100 #define Dbg_Err_DbgTableFormat DbgError(10)
101 #define Dbg_Err_NotVariable DbgError(11)
102 #define Dbg_Err_NoSuchBreakPoint DbgError(12)
103 #define Dbg_Err_NoSuchWatchPoint DbgError(13)
104 #define Dbg_Err_FileLineNotFound DbgError(14)
105 #define Dbg_Err_DbgTableVersion DbgError(15)
106 #define Dbg_Err_NoSuchPath DbgError(16)
107 #define Dbg_Err_StateChanged DbgError(17)
108 #define Dbg_Err_SoftInitialiseError DbgError(18)
109 #define Dbg_Err_CoProRegNotWritable DbgError(19)
110 #define Dbg_Err_NotInHistory DbgError(20)
111 #define Dbg_Err_ContextSyntax DbgError(21)
112 #define Dbg_Err_ContextNoLine DbgError(22)
113 #define Dbg_Err_ContextTwoLines DbgError(23)
114 #define Dbg_Err_VarReadOnly DbgError(24)
115 #define Dbg_Err_FileNewerThanImage DbgError(25)
116 #define Dbg_Err_NotFound DbgError(26)
118 /* functions which evaluate expressions may return this value, to indicate
119 that execution became suspended within a function called in the debugee */
121 /* Functions returning characters take a BufDesc argument, with fields buffer
122 and bufsize being input arguments describing the buffer to be filled, and
123 filled being set on return to the number of bytes written to the buffer
124 (omitting the terminating 0).
127 typedef struct Dbg_BufDesc Dbg_BufDesc;
129 typedef void Dbg_BufferFullProc(Dbg_BufDesc *bd);
135 Dbg_BufferFullProc *p;
139 #define Dbg_InitBufDesc(bd, buf, bytes) \
140 ((bd).buffer = (buf), (bd).size = (bytes), (bd).filled = 0,\
141 (bd).p = NULL, (bd).arg = NULL)
143 #define Dbg_InitBufDesc_P(bd, buf, bytes, fn, a) \
144 ((bd).buffer = (buf), (bd).size = (bytes), (bd).filled = 0,\
145 (bd).p = (fn), (bd).arg = (a))
147 Dbg_Error Dbg_StringToBuf(Dbg_BufDesc *buf, char const *s);
148 Dbg_Error Dbg_BufPrintf(Dbg_BufDesc *buf, char const *form, ...);
150 Dbg_Error Dbg_MsgToBuf(Dbg_BufDesc *buf, msg_t t);
151 Dbg_Error Dbg_BufMsgPrintf(Dbg_BufDesc *buf, msg_t form, ...);
153 #define Dbg_MsgToBuf Dbg_StringToBuf
154 #define Dbg_BufMsgPrintf Dbg_BufPrintf
156 Dbg_Error Dbg_CharToBuf(Dbg_BufDesc *buf, int ch);
158 int Dbg_CIStrCmp(char const *s1, char const *s2);
159 /* Case-independent string comparison, interface as for strcmp */
161 int Dbg_CIStrnCmp(char const *s1, char const *s2, size_t n);
162 /* Case-independent string comparison, interface as for strncmp */
164 void Dbg_ErrorToChars(Dbg_MCState *state, Dbg_Error err, Dbg_BufDesc *buf);
166 typedef int Dbg_RDIResetCheckProc(int);
167 /* Type of a function to be called after each RDI operation performed by the
168 toolbox, with the status from the operation as argument. The value returned
169 is treated as the status. (The intent is to allow the toolbox's client to
170 take special action to handle RDIDbg_Error_Reset).
173 typedef struct Dbg_CoProDesc Dbg_CoProDesc;
175 typedef Dbg_Error Dbg_CoProFoundProc(Dbg_MCState *state, int cpno, Dbg_CoProDesc const *cpd);
176 /* Type of a function to be called when the shape of a coprocessor is discovered
177 by enquiry of the target or agent (via RequestCoProDesc)
180 typedef struct RDIProcVec RDIProcVec;
182 Dbg_Error Dbg_RequestReset(Dbg_MCState *);
184 Dbg_Error Dbg_Initialise(
185 Dbg_ConfigBlock *config, Dbg_HostosInterface const *i,
186 Dbg_RDIResetCheckProc *checkreset, Dbg_CoProFoundProc *coprofound,
187 RDIProcVec const *rdi, Dbg_MCState **statep);
188 /* values in config are updated if they call for default values */
190 void Dbg_Finalise(Dbg_MCState *state, bool targetdead);
195 RDI_MemAccessStats a;
198 /*--------------------------------------------------------------------------*/
200 /* Symbol table management.
201 The structure of a Dbg_SymTable is not revealed. It is created by
202 Dbg_ReadSymbols() or by Dbg_LoadFile(), and associated with the argument
204 Many symbol tables may be concurrently active.
205 A Dbg_SymTable is removed either explicitly (by call to Dbg_DeleteSymbols)
206 or implicitly when a symbol table for an overlapping address range is read.
208 There is a pre-defined symbol table containing entries for ARM registers,
209 co-processor registers and the like.
212 typedef struct Dbg_SymTable Dbg_SymTable;
214 typedef struct Dbg_ImageFragmentDesc {
215 ARMaddress base, limit;
216 } Dbg_ImageFragmentDesc;
227 typedef struct Dbg_ImageDesc {
230 ARMaddress robase, rolimit, rwbase, rwlimit;
232 Dbg_ImageFragmentDesc *fragments;
236 Dbg_ImageDesc *Dbg_ImageAreas(Dbg_SymTable *st);
238 Dbg_SymTable *Dbg_LastImage(Dbg_MCState *state);
240 Dbg_SymTable *Dbg_NewSymTable(Dbg_MCState *state, const char *name);
242 Dbg_Error Dbg_ReadSymbols(Dbg_MCState *state, const char *filename, Dbg_SymTable **st);
243 /* Just read the symbols from the named image. <st> is set to the allocated
245 ? Maybe we could usefully allow other formats than AIF images to describe
246 the symbols (eg) of shared libraries
249 typedef struct Dbg_SymInfo {
255 Dbg_SymInfo *Dbg_AsmSym(Dbg_SymTable *st, ARMaddress addr);
256 int32 Dbg_AsmAddr(Dbg_SymTable *st, int32 line);
257 int32 Dbg_AsmLine(Dbg_SymTable *st, ARMaddress addr);
258 int32 Dbg_AsmLinesInRange(Dbg_SymTable *st, ARMaddress start, ARMaddress end);
260 Dbg_Error Dbg_LoadFile(Dbg_MCState *state, const char *filename, Dbg_SymTable **st);
261 /* load the image into target memory, and read its symbols. <st> is set to
262 the allocated symbol table.
263 A null filename reloads the most recently loaded file (and rereads its
265 Loading an image leaves breakpoints unchanged. If a client wishes
266 otherwise, it must remove the breakpoints explicitly.
269 Dbg_Error Dbg_CallGLoadFile(Dbg_MCState *state, const char *filename, Dbg_SymTable **st);
271 typedef void Dbg_ImageLoadProc(Dbg_MCState *, Dbg_SymTable *);
272 Dbg_Error Dbg_OnImageLoad(Dbg_MCState *, Dbg_ImageLoadProc *);
273 /* Register function to be called back whenever an image is loaded, or symbols
274 * for an image read. (To allow multiple toolbox clients to coexist).
277 Dbg_Error Dbg_LoadAgent(Dbg_MCState *state, const char *filename);
278 /* Load a debug agent, and start it.
279 Symbols in the image for the agent are ignored.
282 Dbg_Error Dbg_RelocateSymbols(Dbg_SymTable *st, ARMaddress reloc);
283 /* add <reloc> to the value of all symbols in <st> describing absolute memory
284 locations. The intent is to allow the symbols in a load-time relocating
285 image (for example) to be useful.
288 Dbg_Error Dbg_DeleteSymbols(Dbg_MCState *state, Dbg_SymTable **st);
290 typedef enum Dbg_LLSymType {
298 /* Since AIF images contain no type information for low-level symbols, this
299 classification is only a guess, and some symbols describing constants will
300 incorrectly be described as code or data.
303 typedef Dbg_Error Dbg_SymProc(
305 const char *symbol, Dbg_LLSymType symtype, ARMaddress value,
308 Dbg_Error Dbg_EnumerateLowLevelSymbols(
309 Dbg_MCState *state, const char *match, Dbg_SymProc *p,
311 /* Call p(name, value) for each low level symbol in the tables of <state>
312 whose name matches the regular expression <match> (a NULL <match> matches
313 any name). Symbols are enumerated in no particular order.
316 /*--------------------------------------------------------------------------*/
318 /* Functions are provided here to allow quick mass access to register values
319 for display. There is no comparable need for quick mass update, so writing
320 should be via Assign().
323 typedef struct Dbg_RegSet {
340 /* bits in the modemask argument for ReadRegisters */
342 #define Dbg_MM_User 1
346 #define Dbg_MM_Abort 0x10
347 #define Dbg_MM_Undef 0x20
348 #define Dbg_MM_System 0x40
350 Dbg_Error Dbg_ReadRegisters(Dbg_MCState *state, Dbg_RegSet *regs, int modemask);
352 Dbg_Error Dbg_WriteRegister(Dbg_MCState *state, int rno, int modemask, ARMword val);
354 int Dbg_StringToMode(const char *name);
356 int Dbg_ModeToModeMask(ARMword mode);
358 /* Some implementations of the FP instruction set keep FP values loaded into
359 registers in their unconverted format, converting only when necessary.
360 Some RDI implementations deliver these values uninterpreted.
361 (For the rest, register values will always have type F_Extended).
364 typedef enum { F_Single, F_Double, F_Extended, F_Packed, /* fpe340 values */
365 F_Internal, /* new fpe : mostly as extended */
368 typedef struct { ARMword w[3]; } Dbg_TargetExtendedVal;
369 typedef struct { ARMword w[3]; } Dbg_TargetPackedVal;
370 typedef struct { ARMword w[2]; } Dbg_TargetDoubleVal;
371 typedef struct { ARMword w[1]; } Dbg_TargetFloatVal;
373 typedef union { Dbg_TargetExtendedVal e; Dbg_TargetPackedVal p;
374 Dbg_TargetDoubleVal d; Dbg_TargetFloatVal f; } Dbg_TargetFPVal;
376 #define TargetSizeof_Extended 12
377 #define TargetSizeof_Packed 12
378 #define TargetSizeof_Double 8
379 #define TargetSizeof_Float 4
381 typedef struct Dbg_FPRegVal {
386 typedef struct Dbg_FPRegSet {
391 Dbg_Error Dbg_ReadFPRegisters(Dbg_MCState *state, Dbg_FPRegSet *regs);
393 Dbg_Error Dbg_WriteFPRegisters(Dbg_MCState *state, int32 mask, Dbg_FPRegSet *regs);
395 Dbg_Error Dbg_FPRegToDouble(DbleBin *d, Dbg_FPRegVal const *f);
396 /* Converts from a FP register value (in any format) to a double with
397 approximately the same value (or returns Dbg_Err_Overflow)
400 void Dbg_DoubleToFPReg(Dbg_FPRegVal *f, DbleBin const *d);
401 /* Converts the double <d> to a Dbg_FPRegVal with type F_Extended */
403 /*--------------------------------------------------------------------------*/
407 Dbg_Error Dbg_DescribeCoPro(Dbg_MCState *state, int cpnum, Dbg_CoProDesc *p);
409 Dbg_Error Dbg_DescribeCoPro_RDI(Dbg_MCState *state, int cpnum, Dbg_CoProDesc *p);
411 Dbg_Error Dbg_ReadCPRegisters(Dbg_MCState *state, int cpnum, ARMword *regs);
413 Dbg_Error Dbg_WriteCPRegisters(Dbg_MCState *state, int cpnum, int32 mask, ARMword *regs);
415 /*--------------------------------------------------------------------------*/
417 Dbg_Error Dbg_ReadWords(
419 ARMword *words, ARMaddress addr, unsigned count);
420 /* Reads a number of (32-bit) words from target store. The values are in host
421 byte order; if they are also to be interpreted as bytes Dbg_SwapByteOrder()
422 must be called to convert to target byte order.
425 Dbg_Error Dbg_WriteWords(
427 ARMaddress addr, const ARMword *words, unsigned count);
428 /* Writes a number of (32-bit) words to target store. The values are in host
429 byte order (if what is being written is actually a byte string it must be
430 converted by Dbg_SwapByteOrder()).
433 Dbg_Error Dbg_ReadHalf(Dbg_MCState *state, ARMhword *val, ARMaddress addr);
434 Dbg_Error Dbg_WriteHalf(Dbg_MCState *state, ARMaddress addr, ARMword val);
436 Dbg_Error Dbg_ReadBytes(Dbg_MCState *state, Dbg_Byte *val, ARMaddress addr, unsigned count);
437 Dbg_Error Dbg_WriteBytes(Dbg_MCState *state, ARMaddress addr, const Dbg_Byte *val, unsigned count);
439 void Dbg_HostWords(Dbg_MCState *state, ARMword *words, unsigned wordcount);
440 /* (A noop unless host and target bytesexes differ) */
442 ARMword Dbg_HostWord(Dbg_MCState *state, ARMword v);
444 ARMhword Dbg_HostHalf(Dbg_MCState *state, ARMword v);
446 /*--------------------------------------------------------------------------*/
448 /* Types describing various aspects of position within code.
449 There are rather a lot of these, in the interests of describing precisely
450 what fields must be present (rather than having a single type with many
451 fields which may or may not be valid according to context).
454 typedef struct Dbg_LLPos {
460 typedef struct Dbg_File {
465 typedef struct Dbg_Line {
466 unsigned32 line; /* linenumber in the file */
467 unsigned16 statement, /* within the line (1-based) */
470 /* As an output value from toolbox functions, both statement and charpos are set
471 if the version of the debugger tables for the section concerned permits.
472 On input, <charpos> is used only if <statement> is 0 (in which case, if
473 <charpos> is non-0, Dbg_Err_DbgTableVersion is returned if the version of
474 the debugger tables concerned is too early.
477 typedef struct Dbg_FilePos {
482 typedef struct Dbg_ProcDesc {
487 typedef struct Dbg_ProcPos {
492 /* Support for conversions between position representations */
494 Dbg_Error Dbg_ProcDescToLine(Dbg_MCState *state, Dbg_ProcDesc *proc, Dbg_Line *line);
495 /* If proc->f.file is null (and there is just one function proc->name), it is
496 updated to point to the name of the file containing (the start of)
500 Dbg_Error Dbg_FilePosToProc(Dbg_MCState *state, const Dbg_FilePos *pos, char **procname);
502 /* Conversions from position representations to and from code addresses */
504 Dbg_Error Dbg_AddressToProcPos(
505 Dbg_MCState *state, ARMaddress addr,
507 Dbg_Error Dbg_AddressToLLPos(
508 Dbg_MCState *state, ARMaddress addr,
509 Dbg_LLPos *pos, Dbg_LLSymType *res_type, int system_names);
511 Dbg_Error Dbg_ProcPosToAddress(
512 Dbg_MCState *state, const Dbg_ProcPos *pos,
514 Dbg_Error Dbg_LLPosToAddress(
515 Dbg_MCState *state, const Dbg_LLPos *pos,
519 ARMaddress start, end;
522 typedef Dbg_Error Dbg_AddressRangeProc(void *arg, int32 first, int32 last, Dbg_AddressRange const *range);
524 Dbg_Error Dbg_MapAddressRangesForFileRange(
526 Dbg_SymTable *st, const char *f, int32 first, int32 last, Dbg_AddressRangeProc *p, void *arg);
528 typedef struct Dbg_Environment Dbg_Environment;
529 /* A Dbg_Environment describes the context required to make sense of a variable
530 name and access its value. Its format is not revealed. Dbg_Environment
531 values are allocated by Dbg_NewEnvironment() and discarded by
532 Dbg_DeleteEnvironment().
535 Dbg_Environment *Dbg_NewEnvironment(Dbg_MCState *state);
536 void Dbg_DeleteEnvironment(Dbg_MCState *state, Dbg_Environment *env);
538 Dbg_Error Dbg_StringToEnv(
539 Dbg_MCState *state, char *str, Dbg_Environment *resenv,
540 int forcontext, Dbg_Environment const *curenv);
542 Dbg_Error Dbg_ProcPosToEnvironment(
543 Dbg_MCState *state, const Dbg_ProcPos *pos, int activation,
544 const Dbg_Environment *current, Dbg_Environment *res);
546 /* Conversion from a position representation to an Dbg_Environment (as required
547 to access variable values). Only a Dbg_ProcPos argument here; other
548 representations need to be converted first.
550 Returns <res> describing the <activation>th instance of the function
551 described by <pos>, up from the stack base if <activation> is negative,
552 else down from <current>.
553 If this function returns Dbg_Err_ActivationNotPresent, the result
554 Dbg_Environment is still valid for accessing non-auto variables.
557 typedef struct Dbg_DeclSpec Dbg_DeclSpec;
559 Dbg_Error Dbg_EnvToProcItem(
560 Dbg_MCState *state, Dbg_Environment const *env, Dbg_DeclSpec *proc);
562 Dbg_Error Dbg_ContainingEnvironment(
563 Dbg_MCState *state, const Dbg_Environment *context, Dbg_Environment *res);
564 /* Set <res> to describe the containing function, file if <context> is within
565 a top-level function (or error if <context> already describes a file).
568 /*--------------------------------------------------------------------------*/
570 /* ASD debug table pointers are not by themselves sufficient description,
571 since there's an implied section context. Hence the DeclSpec and TypeSpec
576 #ifndef Dbg_TypeSpec_Defined
578 struct Dbg_DeclSpec { void *a; };
580 #ifdef CALLABLE_COMPILER
581 typedef void *Dbg_TypeSpec;
583 /* The intention here is to give an alternative definition for Dbg_BasicType
587 #define Dbg_T_Void xDbg_T_Void
588 #define Dbg_T_Bool xDbg_T_Bool
589 #define Dbg_T_SByte xDbg_T_SByte
590 #define Dbg_T_SHalf xDbg_T_Half
591 #define Dbg_T_SWord xDbg_T_SWord
592 #define Dbg_T_UByte xDbg_T_UByte
593 #define Dbg_T_UHalf xDbg_T_UHalf
594 #define Dbg_T_UWord xDbg_T_UWord
595 #define Dbg_T_Float xDbg_T_Float
596 #define Dbg_T_Double xDbg_T_Double
597 #define Dbg_T_LDouble xDbg_T_LDouble
598 #define Dbg_T_Complex xDbg_T_Complex
599 #define Dbg_T_DComplex xDbg_T_DComplex
600 #define Dbg_T_String xDbg_T_String
601 #define Dbg_T_Function xDbg_T_Function
603 #define Dbg_BasicType xDbg_BaiscType
604 #define Dbg_PrimitiveTypeToTypeSpec xDbg_PrimitiveTypeToTypeSpec
607 /* We want a Dbg_TypeSpec to be a an opaque type, but of known size (so the
608 toolbox's clients can allocate the store to hold one); unfortunately, we
609 can do this only by having one definition for the toolbox's clients and
610 one (elsewhere) for the toolbox itself.
613 typedef struct Dbg_TypeSpec Dbg_TypeSpec;
614 struct Dbg_TypeSpec { void *a; int32 b; };
615 #endif /* CALLABLE_COMPILER */
644 void Dbg_PrimitiveTypeToTypeSpec(Dbg_TypeSpec *ts, Dbg_BasicType t);
646 bool Dbg_TypeIsIntegral(Dbg_TypeSpec const *ts);
648 bool Dbg_TypeIsPointer(Dbg_TypeSpec const *ts);
650 bool Dbg_TypeIsFunction(Dbg_TypeSpec const *ts);
652 bool Dbg_PruneType(Dbg_TypeSpec *tsres, Dbg_TypeSpec const *ts);
653 /* Return to tsres a version of ts which has been pruned by the removal of all
654 toplevel typedefs. Result is YES if the result has changed.
657 typedef Dbg_Error Dbg_FileProc(Dbg_MCState *state, const char *name, const Dbg_DeclSpec *procdef, void *arg);
659 Dbg_Error Dbg_EnumerateFiles(Dbg_MCState *state, Dbg_SymTable *st, Dbg_FileProc *p, void *arg);
660 /* The top level for a high level enumerate. Lower levels are performed by
661 EnumerateDeclarations (below).
674 Dbg_DeclSort Dbg_SortOfDeclSpec(Dbg_DeclSpec const *decl);
676 char *Dbg_NameOfDeclSpec(Dbg_DeclSpec const *decl);
678 Dbg_TypeSpec Dbg_TypeSpecOfDeclSpec(Dbg_DeclSpec const *decl);
694 Dbg_StgClass Dbg_StgClassOfDeclSpec(Dbg_DeclSpec const *decl);
696 bool Dbg_VarsAtSameAddress(Dbg_DeclSpec const *d1, Dbg_DeclSpec const *d2);
698 bool Dbg_VarsDecribedForDeclSpec(Dbg_DeclSpec const *decl);
700 int Dbg_ArgCountOfDeclSpec(Dbg_DeclSpec const *decl);
702 typedef struct Dbg_DComplex { DbleBin r, i; } Dbg_DComplex;
704 typedef union Dbg_ConstantVal {
713 typedef struct Dbg_Constant {
718 typedef enum Dbg_ValueSort {
728 /* vs_local allows the use of symbol table entries to describe entities within
729 the debugger's own address space, accessed in the same way as target
731 vs_filtered describes entities which may be read or written only via an
732 access function (eg r15)
736 /* There's only one register ValueSort (reflecting asd table StgClass);
737 fp register n is encoded as register n+fpr_base.
740 typedef struct Dbg_Value Dbg_Value;
742 typedef Dbg_Error Dbg_AccessFn(Dbg_MCState *state, int write, Dbg_Value *self, Dbg_Constant *c);
743 /* <write> == 0: read a vs_filtered value, updating the value self.
744 <write> == 1: update a vs_filtered value, with the value described by c.
745 <self> allows use of the same Dbg_AccessFn for several different entities
746 (using different val.f.id fields).
749 typedef Dbg_Error Dbg_FormatFn(int decode, char *b, ARMword *valp, void *formatarg);
751 typedef struct { Dbg_AccessFn *f; int id; } Dbg_AccessFnRec;
756 Dbg_FormatFn *formatp;
760 struct { int no; ARMaddress frame; } r;
769 Dbg_Error Dbg_AddLLSymbol(Dbg_SymTable *st, char const *name, Dbg_LLSymType type, ARMword val);
771 Dbg_Error Dbg_AddSymbol(Dbg_SymTable *st, char const *name, Dbg_Value const *val);
773 typedef struct Dbg_DeclSpecF {
775 Dbg_FormatFn *formatp;
779 typedef Dbg_Error Dbg_DeclProc(Dbg_MCState *state, Dbg_Environment const *context,
780 Dbg_DeclSpecF const *var, Dbg_DeclSort sort, int masked,
783 Dbg_Error Dbg_EnumerateDeclarations(Dbg_MCState *state, Dbg_Environment const *context,
784 Dbg_DeclProc *p, void *arg);
785 /* call p once for every declaration local to the function described by
786 <context> (or file if <context> describes a place outside a function).
787 p's argument <masked> is true if the variable is not visible, thanks to
788 a declaration in an inner scope.
791 Dbg_Error Dbg_ValueOfVar(Dbg_MCState *state, const Dbg_Environment *context,
792 const Dbg_DeclSpec *var, Dbg_Value *val);
793 /* Different from Dbg_EvalExpr() in that the thing being evaluated is described
794 by a Dbg_DeclSpec (which must be for a variable), rather than a string
795 needing to be decoded and associated with a symbol-table item. Intended to
796 be called from a Dbg_DeclProc called from Dbg_EnumerateDeclarations.
799 Dbg_Error Dbg_EvalExpr(Dbg_MCState *state, Dbg_Environment const *context,
800 char const *expr, int flags, Dbg_Value *val);
802 Dbg_Error Dbg_EvalExpr_ep(Dbg_MCState *state, Dbg_Environment const *context,
803 char const *expr, char **exprend, int flags, Dbg_Value *val);
805 /* Both Dbg_ValueOfVar and Dbg_EvalExpr mostly deliver a value still containing
806 an indirection (since it may be wanted as the lhs of an assignment)
809 void Dbg_RealLocation(Dbg_MCState *state, Dbg_Value *val);
810 /* If val describes a register, this may really be a register, or a place on
811 the stack where the register's value is saved. In the latter case, val
812 is altered to describe the save place. (In all others, it remains
816 Dbg_Error Dbg_DereferenceValue(Dbg_MCState *state, const Dbg_Value *value, Dbg_Constant *c);
817 /* This fails if <value> describes a structure or array, returning
818 Dbg_Err_TypeNotSimple
821 typedef struct Dbg_Expr Dbg_Expr;
822 /* The result of parsing an expression in an environment: its structure is not
823 revealed. (Clients may wish to parse just once an expression which may be
824 evaluated often). In support of which, the following two functions partition
825 the work of Dbg_EvalExpr().
828 #define Dbg_exfl_heap 1 /* allocate Expr on the heap (FreeExpr must then be
829 called to discard it). Otherwise, it goes in a
830 place overwritten by the next call to ParseExpr
833 #define Dbg_exfl_needassign 2
834 #define Dbg_exfl_lowlevel 4
836 int Dbg_SetInputRadix(Dbg_MCState *state, int radix);
837 char *Dbg_SetDefaultIntFormat(Dbg_MCState *state, char *format);
839 Dbg_Error Dbg_ParseExpr(
840 Dbg_MCState *state, Dbg_Environment const *env, char *string,
841 char **end, Dbg_Expr **res, int flags);
842 /* Just parse the argument string, returning a pointer to a parsed expression
843 and a pointer to the first non-white space character in the input string
844 which is not part of the parsed expression. (If macro expansion has taken
845 place, the returned pointer will not be into the argument string at all,
846 rather into the expanded version of it).
849 Dbg_Error Dbg_ParseExprCheckEnd(
850 Dbg_MCState *state, Dbg_Environment const *env, char *string,
851 Dbg_Expr **res, int flags);
852 /* As Dbg_ParseExpr, but the parsed expression is required completely to fill
853 the argument string (apart possibly for trailing whitespace), and an error
854 is returned if it does not.
857 Dbg_Error Dbg_ParsedExprToValue(
858 Dbg_MCState *state, const Dbg_Environment *env, Dbg_Expr *expr, Dbg_Value *v);
860 Dbg_Error Dbg_ReadDecl(
861 Dbg_MCState *state, Dbg_Environment const *env, char *string,
862 Dbg_TypeSpec *p, char **varp, int flags);
863 /* Read a variable declaration, returing a description of the type of the
864 variable to p, and a pointer to its name to varp.
867 bool Dbg_IsCastToArrayType(Dbg_MCState *state, Dbg_Expr *expr);
869 void Dbg_FreeExpr(Dbg_Expr *expr);
871 Dbg_Error Dbg_CopyType(Dbg_TypeSpec *tdest, Dbg_TypeSpec const *tsource);
872 Dbg_Error Dbg_FreeCopiedType(Dbg_TypeSpec *ts);
874 Dbg_Error Dbg_TypeOfExpr(Dbg_MCState *state, Dbg_Expr *tree, Dbg_TypeSpec *restype);
876 Dbg_Error Dbg_ExprToVar(const Dbg_Expr *expr, Dbg_DeclSpec *var, Dbg_Environment *env);
878 Dbg_Error Dbg_Assign(Dbg_MCState *state, const Dbg_Value *lv, const Dbg_Value *rv);
880 typedef enum Dbg_TypeSort {
887 Dbg_TypeSort Dbg_TypeSortOfValue(Dbg_MCState *state, const Dbg_Value *val, int *fieldcount);
889 Dbg_Error Dbg_TypeToChars(const Dbg_TypeSpec *var, Dbg_BufDesc *buf);
891 Dbg_Error Dbg_TypeSize(Dbg_MCState *state, const Dbg_TypeSpec *type, unsigned32 *res);
893 typedef int Dbg_ValToChars_cb(Dbg_MCState *state, Dbg_Value *subval, const char *fieldname,
894 Dbg_BufDesc *buf, void *arg);
896 Dbg_Error Dbg_ValToChars(Dbg_MCState *state, Dbg_Value *val, int base,
897 Dbg_ValToChars_cb *cb, void *arg,
898 const char *form, Dbg_BufDesc *buf);
900 <base> is used for (any size) integer values.
901 If <val> is of an array or structure type, <cb> is called for each element,
902 with <arg> as its last parameter, and <subbuf> describing the space remaining
903 in <buf>. If <cb> returns 0, conversion ceases.
906 Dbg_Error Dbg_NthElement(
908 const Dbg_Value *val, unsigned32 n, char **fieldname, Dbg_Value *subval);
910 typedef Dbg_Error Dbg_HistoryProc(void *, int, Dbg_Value *);
912 Dbg_Error Dbg_RegisterHistoryProc(Dbg_MCState *state, Dbg_HistoryProc *p, void *arg);
925 struct { ARMaddress addr, size; } store;
926 struct { int modemask; int r; } cpu;
927 struct { int no; int r; } cp;
933 typedef Dbg_Error Dbg_ObjectWriteProc(Dbg_MCState *state, Dbg_Loc const *loc);
934 Dbg_Error Dbg_OnObjectWrite(Dbg_MCState *state, Dbg_ObjectWriteProc *p);
935 /* Register function to be called back whenever the toolbox has written to any
936 * object accessible by the debuggee (or to local variables belonging to a
937 * toolbox client). The write has already been done.
938 * (To allow multiple toolbox clients to coexist).
941 Dbg_Error Dbg_ObjectWritten(Dbg_MCState *state, Dbg_Loc const *loc);
943 /*--------------------------------------------------------------------------*/
945 /* Control of target program execution.
946 Currently, only synchronous operation is provided.
947 Execution could possibly be asynchronous where the target is a seperate
948 processor, but is necessarily synchronous if the target is Armulator.
949 Unfortunately, this may require modification to the RDI implementation
950 if multitasking is required but the the host system provides it only
951 cooperatively, or if there is no system-provided way to generate SIGINT.
954 Dbg_Error Dbg_SetCommandline(Dbg_MCState *state, const char *args);
955 /* Set the argument string to the concatenation of the name of the most
956 recently loaded image and args.
959 typedef enum Dbg_ProgramState {
961 /* Normal ways of stopping */
962 ps_atbreak, ps_atwatch, ps_stepdone,
965 /* abnormal (but unsurprising) ways of stopping */
967 ps_branchthrough0, ps_undef, ps_caughtswi, ps_prefetch,
968 ps_abort, ps_addrexcept, ps_caughtirq, ps_caughtfiq,
970 /* only as a return value from Call() */
971 ps_callfailed, ps_callreturned,
972 /* internal inconsistencies */
973 ps_broken, /* target has "broken" */
978 int Dbg_IsCallLink(Dbg_MCState *state, ARMaddress pc);
985 Dbg_CallResults *Dbg_GetCallResults(Dbg_MCState *state);
987 #define Dbg_S_STATEMENTS 0
988 #define Dbg_S_INSTRUCTIONS 1
989 #define Dbg_S_STEPINTOPROCS 2
991 Dbg_Error Dbg_Step(Dbg_MCState *state, int32 stepcount, int stepby, Dbg_ProgramState *status);
992 /* <stepby> is a combination of the Dbg_S_... values above */
994 Dbg_Error Dbg_StepOut(Dbg_MCState *state, Dbg_ProgramState *status);
996 bool Dbg_CanGo(Dbg_MCState *state);
998 bool Dbg_IsExecuting(Dbg_MCState *state);
1000 Dbg_Error Dbg_Go(Dbg_MCState *state, Dbg_ProgramState *status);
1002 Dbg_Error Dbg_Stop(Dbg_MCState *state);
1003 /* Asynchronous Stop request, for call from SIGINT handler. On return to the
1004 caller, the call of Dbg_Go, Dbg_Step or Dbg_Call which started execution
1005 should return ps_interrupted.
1008 typedef void Dbg_ExecuteProc(Dbg_MCState *state, Dbg_ProgramState status);
1009 Dbg_Error Dbg_OnExecute(Dbg_MCState *, Dbg_ExecuteProc *);
1010 /* Register function to be called back whenever execution stops.
1011 * (To allow multiple toolbox clients to coexist).
1014 Dbg_Error Dbg_SetReturn(Dbg_MCState *state,
1015 const Dbg_Environment *context, const Dbg_Value *value);
1016 /* Prepare continuation by returning <value> from the function activation
1017 described by <context>. (Dbg_Go() or Dbg_Step() actually perform the
1021 Dbg_Error Dbg_SetExecution(Dbg_MCState *state, Dbg_Environment *context);
1022 /* Set the pc in a high-level fashion */
1024 Dbg_Error Dbg_ProgramStateToChars(Dbg_MCState *state, Dbg_ProgramState event, Dbg_BufDesc *buf);
1025 /* This is guaranteed to give a completely accurate description of <event> if
1026 this was the value returned by the most recent call of Dbg_Go, Dbg_Step,
1030 /*--------------------------------------------------------------------------*/
1032 Dbg_Error Dbg_CurrentEnvironment(Dbg_MCState *state, Dbg_Environment *context);
1034 Dbg_Error Dbg_PrevFrame(Dbg_MCState *state, Dbg_Environment *context);
1035 /* towards the base of the stack */
1037 Dbg_Error Dbg_NextFrame(Dbg_MCState *state, Dbg_Environment *context);
1038 /* away from the base of the stack */
1040 typedef struct Dbg_AnyPos {
1041 enum { pos_source, pos_ll, pos_none } postype;
1050 Dbg_Error Dbg_EnvironmentToPos(Dbg_MCState *state, const Dbg_Environment *context, Dbg_AnyPos *pos);
1051 /* <pos> is set to a Dbg_ProcPos if these is one corresponding to <context>
1052 else a Dbg_LLPos if there is one.
1055 /*--------------------------------------------------------------------------*/
1057 /* Source file management.
1058 Pretty vestigial. Handles source path (per loaded image),
1059 and translates from line-number (as given in debugger tables) to character
1060 position (as required to access files)
1063 Dbg_Error Dbg_ClearPaths(Dbg_MCState *state, Dbg_SymTable *st);
1064 Dbg_Error Dbg_AddPath(Dbg_MCState *state, Dbg_SymTable *st, const char *path);
1065 Dbg_Error Dbg_DeletePath(Dbg_MCState *state, Dbg_SymTable *st, const char *path);
1071 } Dbg_PathAlteration;
1073 typedef void Dbg_PathAlteredProc(
1074 Dbg_MCState *state, Dbg_SymTable *st, char const *path,
1075 Dbg_PathAlteration sort);
1077 Dbg_Error Dbg_OnPathAlteration(Dbg_MCState *state, Dbg_PathAlteredProc *p);
1078 /* Register function to be called back whenever one of the source path
1079 * modification functions above is called. (To allow multiple toolbox
1080 * clients to coexist).
1083 typedef struct Dbg_FileRec Dbg_FileRec;
1085 unsigned32 linecount;
1086 Dbg_FileRec *handle;
1090 Dbg_Error Dbg_GetFileDetails(
1091 Dbg_MCState *state, const Dbg_File *fname, Dbg_FileDetails *res);
1092 Dbg_Error Dbg_FinishedWithFile(Dbg_MCState *state, Dbg_FileRec *handle);
1094 Dbg_Error Dbg_GetFileDetails_fr(
1095 Dbg_MCState *state, Dbg_FileRec *handle, Dbg_FileDetails *res);
1096 /* Refresh details about the file associated with <handle> (in particular,
1100 Dbg_Error Dbg_FileLineLength(
1101 Dbg_MCState *state, Dbg_FileRec *handle, int32 lineno, int32 *len);
1102 /* Return to <len> the length of line <lineno> of the file associated with
1103 * <handle> (without necessarily reading from the file).
1106 Dbg_Error Dbg_GetFileLine_fr(
1107 Dbg_MCState *state, Dbg_FileRec *handle, int32 lineno, Dbg_BufDesc *buf);
1108 /* Return to <buf> the contents of line <lineno> of the file associated with
1109 * <handle> (including its terminating newline).
1112 Dbg_Error Dbg_StartFileAccess(Dbg_MCState *state, Dbg_FileRec *handle);
1113 Dbg_Error Dbg_EndFileAccess(Dbg_MCState *state, Dbg_FileRec *handle);
1114 /* These two calls bracket a sequence of calls to GetFileLine. Between the
1115 * calls, the toolbox is permitted to retain state allowing more rapid
1116 * access to text on the file associated with <handle>.
1119 Dbg_Error Dbg_ControlSourceFileAccess(
1120 Dbg_MCState *state, uint32 cachesize, bool closefiles);
1121 /* Control details of how the toolbox manages source files.
1122 * If <cachesize> is non-zero, the text from the most recently accessed
1123 * source files (of total size not to exceed <cachesize>) is saved in
1124 * store on first access to the file; subsequent access to the text of
1125 * the file uses this copy.
1126 * If <closefiles> is true, no stream is left attached to uncached source
1127 * files after Dbg_EndFileAccess has been closed. Otherwise, the toolbox
1128 * may retain such streams, in order to improve access.
1131 /*--------------------------------------------------------------------------*/
1136 ? More exact control is wanted here, but that requires a more complicated
1137 ? disass callback interface.
1140 typedef const char *Dbg_SWI_Decode(Dbg_MCState *state, ARMword swino);
1142 Dbg_Error Dbg_InstructionAt(Dbg_MCState *state, ARMaddress addr,
1143 int isize, ARMhword *inst, Dbg_SymTable *st,
1144 Dbg_SWI_Decode *swi_name, Dbg_BufDesc *buf, int *length);
1145 /* <isize> describes the form of disassembly wanted: 2 for 16-bit, 4 for 32-bit,
1146 * 0 for 16- or 32-bit depending whether addr addresses 16- or 32-bit code.
1147 * <inst> is a pointer to a pair of halfwords *in target byte order*
1148 * Possibly only the first halfword will be consumed: the number of bytes used
1149 * is returned via <length>.
1152 /*--------------------------------------------------------------------------*/
1154 int Dbg_RDIOpen(Dbg_MCState *state, unsigned type);
1155 int Dbg_RDIInfo(Dbg_MCState *state, unsigned type, ARMword *arg1, ARMword *arg2);
1157 /*--------------------------------------------------------------------------*/
1161 Dbg_Point_RDI_Unknown,
1166 /* breakpoint management
1167 Associated with a breakpoint there may be any of
1171 the breakpoint is activated if
1172 the expression evaluates to a non-zero value (or fails to evaluate).
1173 && decrementing the count reaches zero (the count is then reset to its
1175 && the function, called with the breakpoint address as argument, returns
1177 ? (The order here may be open to debate. Note that the first two are in
1178 the opposite order in armsd, but I think this order more rational)
1181 typedef enum Dbg_BreakPosType {
1188 Dbg_ProcPos procpos;
1189 Dbg_ProcDesc procexit;
1193 typedef struct Dbg_BreakPos {
1194 Dbg_BreakPosType sort;
1195 Dbg_BreakPosPos loc;
1198 typedef int Dbg_BPProc(Dbg_MCState *state, void *BPArg, Dbg_BreakPos *where);
1200 typedef struct Dbg_BreakStatus {
1202 int initcount, countnow;
1205 Dbg_BPProc *p; void *p_arg;
1211 Dbg_Error Dbg_StringToBreakPos(
1212 Dbg_MCState *state, Dbg_Environment *env, char const *str, size_t len,
1213 Dbg_BreakPos *bpos, char *b);
1215 Dbg_Error Dbg_SetBreakPoint(Dbg_MCState *state, Dbg_BreakPos *where,
1218 Dbg_BPProc *p, void *arg);
1219 Dbg_Error Dbg_SetBreakPoint16(Dbg_MCState *state, Dbg_BreakPos *where,
1222 Dbg_BPProc *p, void *arg);
1223 Dbg_Error Dbg_SetBreakPointNaturalSize(Dbg_MCState *state, Dbg_BreakPos *where,
1226 Dbg_BPProc *p, void *arg);
1227 /* Setting a breakpoint at the same address as a previous breakpoint
1228 completely removes the previous one.
1231 Dbg_Error Dbg_DeleteBreakPoint(Dbg_MCState *state, Dbg_BreakPos *where);
1233 Dbg_Error Dbg_SuspendBreakPoint(Dbg_MCState *state, Dbg_BreakPos *where);
1234 /* Temporarily remove the break point (until Reinstated) but leave intact
1235 its associated expr, the value its count has reached, etc.
1236 ? The debugger toolbox itself wants this, but I'm not sure what use a client
1237 could have for it. Ditto Reinstate...
1240 Dbg_Error Dbg_ReinstateBreakPoint(Dbg_MCState *state, Dbg_BreakPos *where);
1241 /* Undo the effect of Dbg_SuspendBreakPoint
1244 Dbg_Error Dbg_DeleteAllBreakPoints(Dbg_MCState *state);
1246 Dbg_Error Dbg_SuspendAllBreakPoints(Dbg_MCState *state);
1248 Dbg_Error Dbg_ReinstateAllBreakPoints(Dbg_MCState *state);
1250 typedef Dbg_Error Dbg_BPEnumProc(Dbg_MCState *state, Dbg_BreakStatus *status, void *arg);
1252 Dbg_Error Dbg_EnumerateBreakPoints(Dbg_MCState *state, Dbg_BPEnumProc *p, void *arg);
1254 Dbg_Error Dbg_BreakPointStatus(Dbg_MCState *state,
1255 const Dbg_BreakPos *where, Dbg_BreakStatus *status);
1257 typedef void Dbg_BreakAlteredProc(Dbg_MCState *state, ARMaddress addr, bool set);
1258 Dbg_Error Dbg_OnBreak(Dbg_MCState *state, Dbg_BreakAlteredProc *p);
1259 /* Register function to be called back whenever a breakpoint is set or
1260 * cleared. (To allow multiple toolbox clients to coexist).
1263 bool Dbg_StoppedAtBreakPoint(Dbg_MCState *state, const Dbg_BreakPos *where);
1264 /* Called after execution which resulted in ps_atbreak, to find out whether
1265 the specified breakpoint was hit (could be >1, eg. exit break and another
1266 high-level breakpoint at the same position).
1267 Returns NO if specified breakpoint not found, or execution didn't stop
1268 with ps_atbreak status.
1271 /*--------------------------------------------------------------------------*/
1278 typedef int Dbg_WPProc(Dbg_MCState *state, void *WPArg, Dbg_WatchPos *where);
1280 typedef struct Dbg_WPStatus {
1282 int initcount, countnow;
1283 Dbg_WatchPos what, target;
1285 Dbg_WPProc *p; void *p_arg;
1291 Dbg_Error Dbg_SetWatchPoint(
1292 Dbg_MCState *state, Dbg_Environment *context, char const *watchee,
1296 Dbg_WPProc *p, void *arg);
1298 /* Cause a watchpoint event if the value of <watchee> changes to the value of
1299 <target> (or changes at all if <target> is NULL). <watchee> should
1300 evaluate either to an L-value (when the size of the object being watched is
1301 determined by its type) or to an integer constant (when the word with this
1302 address is watched).
1305 Dbg_Error Dbg_DeleteWatchPoint(Dbg_MCState *state, Dbg_Environment *context, char const *watchee);
1308 Dbg_Error Dbg_SetWatchPoint_V(
1310 char const *name, Dbg_Value const *val, char const *tname, Dbg_Value const *tval,
1313 Dbg_WPProc *p, void *arg);
1315 Dbg_Error Dbg_DeleteWatchPoint_V(Dbg_MCState *state, Dbg_Value const *val);
1318 Dbg_Error Dbg_DeleteAllWatchPoints(Dbg_MCState *state);
1320 typedef Dbg_Error Dbg_WPEnumProc(Dbg_MCState *state, Dbg_WPStatus const *watchee, void *arg);
1322 Dbg_Error Dbg_EnumerateWatchPoints(Dbg_MCState *state, Dbg_WPEnumProc *p, void *arg);
1324 Dbg_Error Dbg_WatchPointStatus(Dbg_MCState *state,
1325 Dbg_WatchPos const *where, Dbg_WPStatus *status);
1327 typedef void Dbg_WPRemovedProc(void *arg, Dbg_WPStatus const *wp);
1328 Dbg_Error Dbg_RegisterWPRemovalProc(Dbg_MCState *state, Dbg_WPRemovedProc *p, void *arg);
1329 /* When a watchpoint goes out of scope it is removed by the toolbox, and the
1330 function registered here gets called back to adjust its view
1333 typedef void Dbg_WatchAlteredProc(Dbg_MCState *state, Dbg_Value const *where, bool set);
1334 Dbg_Error Dbg_OnWatch(Dbg_MCState *state, Dbg_WatchAlteredProc *p);
1335 /* Register function to be called back whenever a watchpoint is set or
1336 * cleared. (To allow multiple toolbox clients to coexist).
1339 /*--------------------------------------------------------------------------*/
1341 Dbg_Error Dbg_ProfileLoad(Dbg_MCState *state);
1343 Dbg_Error Dbg_ProfileStart(Dbg_MCState *state, ARMword interval);
1344 Dbg_Error Dbg_ProfileStop(Dbg_MCState *state);
1346 Dbg_Error Dbg_ProfileClear(Dbg_MCState *state);
1348 Dbg_Error Dbg_WriteProfile(Dbg_MCState *state, char const *filename,
1349 char const *toolid, char const *arg);
1351 /*--------------------------------------------------------------------------*/
1353 Dbg_Error Dbg_ConnectChannel_ToHost(Dbg_MCState *state, RDICCProc_ToHost *p, void *arg);
1354 Dbg_Error Dbg_ConnectChannel_FromHost(Dbg_MCState *state, RDICCProc_FromHost *p, void *arg);
1356 /*--------------------------------------------------------------------------*/
1358 /* Configuration data management */
1360 Dbg_Error Dbg_LoadConfigData(Dbg_MCState *state, char const *filename);
1362 Dbg_Error Dbg_SelectConfig(
1364 RDI_ConfigAspect aspect, char const *name, RDI_ConfigMatchType matchtype,
1365 unsigned versionreq, unsigned *versionp);
1367 Dbg_Error Dbg_ParseConfigVersion(
1368 char const *s, RDI_ConfigMatchType *matchp, unsigned *versionp);
1370 typedef Dbg_Error Dbg_ConfigEnumProc(Dbg_MCState *state, RDI_ConfigDesc const *desc, void *arg);
1372 Dbg_Error Dbg_EnumerateConfigs(Dbg_MCState *state, Dbg_ConfigEnumProc *p, void *arg);
1374 /*--------------------------------------------------------------------------*/
1376 /* Angel OS support */
1378 Dbg_Error Dbg_CreateTask(Dbg_MCState **statep, Dbg_MCState *parent, bool inherit);
1379 /* This is called when a task is to be debugged which has not been debugged
1380 before - ie. there is no existing Dbg_MCState for this task. It
1381 initialises a new Dbg_MCState and returns a pointer to it.
1382 <parent> is any valid previously-created MCCState. If <inherit> is TRUE,
1383 the new MCState inherits certain features from it (eg. symbols).
1384 Otherwise, only features which are the same across all tasks are inherited,
1385 (eg. global breakpoints).
1388 Dbg_Error Dbg_DeleteTask(Dbg_MCState *state);
1389 /* This is called when a task dies, and frees up everything which relates to that
1390 task which is controlled by armdbg.
1393 Dbg_Error Dbg_DetachTask(Dbg_MCState *state);
1395 Dbg_Error Dbg_AttachTask(Dbg_MCState *state);
1396 /* These are called to request a switch of the current task. First
1397 Dbg_DetachTask should be called with the state of the old task.
1398 Dbg_DetachTask will ensure that any cached state held by armdbg for
1399 the old task is immediately written out to the target.
1401 After Dbg_DetachTask is called and before Dbg_AttachTask is called
1402 the OS channel manager should tell the target that any future
1403 requests from the debugger will be fore the new task.
1405 If the new task does not have an armdbg state structure
1406 already, then Dbg_CreateTask should be called to create one (see
1407 above). Then Dbg_AttachTask is called to tell armdbg to treat the
1408 new armdbg state as the current task.
1411 typedef Dbg_Error Dbg_TaskSwitchProc(void *arg, Dbg_MCState *newstate);
1413 Dbg_Error Dbg_OnTaskSwitch(Dbg_MCState *state, Dbg_TaskSwitchProc *fn, void *arg);
1414 /* The front end may register a callback which gets called by armdbg whenever
1415 Dbg_AttachTask is called. This callback tells the front end the new current
1416 Dbg_MCState it should use to call armdbg.
1417 [Note that this is only useful if there is one front end shared between all
1418 tasks rather than one front end per task]
1419 The value of <arg> passed to Dbg_OnTaskSwitch is passed to <fn>
1423 typedef Dbg_Error Dbg_RestartProc(
1424 void *arg, Dbg_MCState *curstate, Dbg_MCState **newstate);
1426 Dbg_Error Dbg_OnRestart(Dbg_MCState *state, Dbg_RestartProc *fn, void *arg);
1427 /* This is used by the OS channels layer to register a callback which
1428 will be made by the debugger toolbox early in the process of resuming
1431 This callback must determine which task will be resumed when the target
1432 restarts execution. If this is not already the current task then it must
1433 call Dbg_DetachTask and Dbg_AttachTask as decribed above to switch to the
1434 task about to be resumed and return the state for the new task in
1437 This will ensure that armdbg updates the correct task on execution as well
1438 as ensuring that stepping over a breakpointed instruction on restarting
1441 The value of <arg> passed to Dbg_OnRestart is passed to <fn>
1452 /* End of armdbg.h */