k%Writing SDA Extensions.

Writing SDA Extensions


9Previous6 | Contents


DThe dump header contains information about the crash (date and time @when the crash occured, size and type of the dump stored in the Gdumpfile, the bugcheck code, processor registers and others). The dump Hheader is held by SDA in virtual memory for the entire SDA session. You Hcan use the SHOW CRASH command to display its contents Gin a readable way. You can use SHOW HEADER to display it as unformatted dump.

GThe errlog buffers contain errorlog information not yet written to the Gerrorlog file, uppercase sc SYS$ERRORLOG:ERRLOG.SYS. GThe system parameters ERRORLOGBUFFERS and ERLBUFFERPAGES determine the size of this area.

GThe hdrbuf and errlogbuf arguments point to internal ESDA buffers, readable from user mode. Although the contents of these Dbuffers is writable as well, you should avoid to change information Etherein. Otherwise, the SDA commands SHOW CRASH and 4SHOW HEADER may not work correctly.

GThe contents of the buffers listed above is useful only when analyzing Ha system dump. On a running system, these buffers exist as well, but do Šnot contain useful data. Therefore, you should always call SDA$EXTEND_ON_CURRENT_SYSTEM before you invoke this callback.

EThis callback is available on Alpha only, there is no replacement on GVAX. SDA's SHOW HEADER command may be used to display the dump header on VAX. 


/

Condition values returned

2



Example


void *hdrbuf,*errlogbuf; int hdrlen,errloglen;  NSDA$EXTEND_GET_HEADER(&hdrbuf,&hdrlen,&errlogbuf,&errloglen);  


DThis example uses SDA$EXTEND_GET_HEADER to get pointers to the dump Cheader and errorlog buffers, as well information about their sizes.


8

SDA$EXTEND_GET_HW_NAME



#Returns the system's hardware name.



Format

'

SDA$EXTEND_GET_HW_NAME retbuf




RETURNS



0This callback does not return a condition value.




ARGUMENTS



retbuf


                
 VMS usage:  ASCIC_char_string
type:  character string
access:  write only
 mechanism:  by reference

BAddress of a buffer which receives the hardware name string. This Fbuffer should provide enough space to accomodate the largest possible Ehardware name (up to 80 bytes). Note that this argument is passed by &reference, not by descriptor.



DESCRIPTION

@This callback returns the system hardware name stored at global Elocation EXE$GT_HWNAME. If this location is unreadable (as it may be Hthe case with an incomplete system dump), SDA uses the system marketing Hmodel number (SMMN) from the SCB (system control block) and an internal Ctable to obtain the hardware name. The string is returned in ASCIC (Counted ASCII) format.

EThis callback is available on Alpha only. On VAX, you can obtain the Dhardware name directly from the location shown above (see 'Example' section).


/

Condition values returned

2



Example


char hw_nam_buf[80];  char *hwnam_ptr;  ASDA$EXTEND_GET_HW_NAME(hw_nam_buf);                  /* Alpha */  ?$DESCRIPTOR(hw_name,"EXE$GT_HWNAME");                /* VAX */  VSDA_EXTEND_SYMBOL_VALUE(&hw_name,&hwnam_ptr);        /* Get ptr to hw name */  HSDA$EXTEND_REQMEM(hw_nam_ptr,hw_nam_buf,hw_nam_ptr[0]); /* Copy name */  


8In this example, the hardware name is written to buffer Fhw_nam_buf for further use. The last three lines show how to emulate the callback on VAX.


:

SDA$EXTEND_GET_IMAGE_OFF



7Maps an image and returns image and offset information.



Format

A

SDA$EXTEND_GET_IMAGE_OFF basadr, imgptr, subptr, offset




RETURNS

                
 VMS usage: bitmsk
type:  mask_longword
access:  write only
 mechanism:  by value


DA bitmask containing additional information about the nature of the Fresultant image or image section. If 0 is returned (no bits are set), Dthe given virtual address could not be mapped in any of the current Eprocess activated or system loaded images. The following bits may be set in the bit mask: # . &                           
Bit Name Bitmask value (hex) Description
 SDA$M_VALID 0001 * An image could be mapped (status OK)
 SDA$M_PROCESS 0002 I If set, the image is process-activated, otherwise, it is an system $ (executive) image in S0 space.
 SDA$M_SLICED 0004 ? If set, the image is sliced, otherwise, it is not sliced.
 SDA$M_COMPRESSED 0008 L If set, the mapped section is a compressed image data section (sliced % process-activated images only).
 SDA$M_ISD_INDEX 0070 J These 3 bits determine the section type in case of sliced executive images.


HNote that the bit names shown in the table are not defined anywhere; if Ayou want to use it in your code, you must define the appropriate literals yourself.




ARGUMENTS



basadr


                
 VMS usage: address
type:  longword (unsigned)
access:  read only
 mechanism:  by value

.A longword holding the virtual address to map.

imgptr


                
 VMS usage: address
type:  longword (unsigned)
access:  write only
 mechanism:  by reference

BThe address of a longword receiving a pointer to a data structure Ccontaining image-related information (see the Description section).

subptr


                
 VMS usage: address
type:  longword (unsigned)
access:  write only
 mechanism:  by reference

BThe address of a longword receiving a pointer to a data structure Ccontaining additional information (for sliced images only; see the Description section).

offset


                
 VMS usage: address
type:  longword (unsigned)
access:  write only
 mechanism:  by reference

EThe address of a longword receiving the byte offset from the image's Fbase address or - in the case of sliced images - from the appropriate image section's base address.



DESCRIPTION

BThis callback provides an interface to SDA's MAP Ccommand. Given a virtual address, the callback searches the loaded Fexeclets data structures and user-activated images data structures to Dfind the image section which the address belongs to. If an image is Efound, information about it can be obtained from the data structures 1addressed by imgptr and subptr.

FThe requested address can be found in one of three areas: in an image Fsection from a loaded executive image (also called execlec), Ein a resident section for an installed user-activated image, or in a Fnormal user-activated image. The first two cases apply to system (S0) Haddresses only, the third applies to per-process (P0/P1) addresses only.

.On Alpha, the following kinds of images exist:



AThe following table gives an overview about the image types, the Faddress spaces at which they are mapped, the bits set in the returned Bbitmask, and the data structures addressed by imgptr and Gsubptr. Note that the SDA$M_ prefix is omitted for the reason Gof shortness. In addition, note that the SDA$M_VALID bit is always set. % ! 4 ! !                              
Image type AdrSpc Bits set in return status imgptr subptr
 Executive image  S0  - LDRIMG  -
 Sliced exec. image  S0 SLICED LDRIMG  LDRIMG_ISD
 Process-activated image  P0 PROCESS IMCB  -
 Process-act. sliced image S0,P1  PROCESS+SLICED IMCB KFERES


BNote that imgptr and subptr do not point to the Hactual data structures in S0 or P1 space, instead they point to buffers Bwherein the data structures were copied by SDA. These buffers are readable from user mode.

GIn case of sliced executive images, the SDA$M_INDEX bits determine the =type of image section. The following table lists these types: " '                          
Bitmask Section type
 00000000 Nonpaged read-only section
 00000010 ! Nonpaged read/write section
 00000020  Paged read-only section
 00000030  Paged read/write section
 00000040  Fixup section
 00000050 D Initialization section (used only during image initialization)


CIn case of sliced process-activated images, the SDA$M_COMPRESS bit 3determine the section type in conjunction with the BKFERES$L_SECTION_TYPE and KFERES$L_SECTION_FLAGS longwords in the KFERES block:



GSee the description of the SDA's MAP command for more information.

DThis callback is available on Alpha only; it is not required on VAX 2since there are no sliced images on this platform.


/

Condition values returned

1
AOnly bit 0 is used to indicate a condition. If bit 0 is set, the Gspecified address could be mapped into an image and the remaining bits Fcontain additional information about this image. If bit 0 is cleared, Fthe specified address could not be mapped and all other bits, as well Himgptr and subptr, do not contain useful information.



Example


 void *imgptr, *subptr, *offset; 
int bitmask;  Qbitmask = SDA$EXTEND_GET_IMAGE_OFF(0x22000,&imgptr,&subptr,&offset);  


HThis call obtains information about the image at address 0x22000. Since >this is a P0 address, it belongs to a process-activated image.


6

SDA$EXTEND_GET_INPUT



Obtains input from the user.



Format

9

SDA$EXTEND_GET_INPUT outbuf, [prompt], [outlen]




RETURNS

                
 VMS usage:  cond_value
type:  longword (unsigned)
access:  write only
 mechanism:  by value



ARGUMENTS



outbuf


                
 VMS usage:  char_string
type:  character string
access:  write only
 mechanism: 4 by descriptor - fixed-length string descriptor

AString that SDA$EXTEND_GET_INPUT gets from the input device. The >outbuf argument is the address of a character string Hdescriptor pointing to the buffer into which the text received from the input device is written.

prompt


                
 VMS usage:  char_string
type:  character string
access:  read only
 mechanism: 4 by descriptor - fixed-length string descriptor

GPrompt message that is displayed on the input device. This argument is Goptional; if you omit it and prompting must occur, the string DATA> is used instead.

outlen


                
 VMS usage:  word_unsigned
type:  word (unsigned)
access:  by reference
 mechanism:

CNumber of bytes written into outbuf. This argument is the Gaddress of an unsigned word containing this number. It is optional; if Fyou do not supply it, information about the returned string length is not given.



DESCRIPTION

BThis routine is the SDA replacement for the general-purpose input Croutine LIB$GET_INPUT. You should always use this routine since it 3provides access to user-defined keys (defined with FDEFINE/KEY) and SDA's enhanced command recall buffer.

EThe routine takes the same arguments as LIB$GET_INPUT and internally Finvokes SMG$READ_COMPOSED_LINE to read data from keyboard or file. If Dyou're unsure how it behaves, look at the RTL Screen Management (SMG$) manual.


.

Condition values returned

            
 SS$_NORMAL # Normal successful completion.
 RMS$_EOF  End of file detected or [CTRL] [Z] was typed.
= Any other condition returned by SMG$READ_COMPOSED_LINE.



Example

lSection 2.3.1 contains a code example of SDA$EXTEND_GET_INPUT.

;

SDA$EXTEND_GET_LINE_COUNT



Returns the current line count.



Format

*

SDA$EXTEND_GET_LINE_COUNT lincnt




RETURNS



0This callback does not return a condition value.




ARGUMENTS



lincnt


                
 VMS usage: address
type:  longword (unsigned)
access:  write only
 mechanism:  by reference

7Address of a longword receiving the current line count.



DESCRIPTION

HThis callback returns the current line count. The line count is used by ASDA to maintain a page-oriented display. Whenever the line count }reaches the end of current page, SDA invoke SDA$EXTEND_NEW_PAGE to perform page-related operations.

}You can use the SDA$EXTEND_ENSURE callback to ensure that a required number rof lines is available. If they aren't, SDA$EXTEND_ENSURE invokes €SDA$EXTEND_NEW_PAGE to insert a new page. In contrast, this callback lets you Gobtain the current line position without inserting a new page, even if (the current page end is already reached.

HThis callback is available on Alpha V7 only, there is no replacement on &earlier Alpha VMS versions and on VAX.


/

Condition values returned

2



Example


int lines;  'SDA$EXTEND_GET_LINE_COUNT(&lines);  


EThis will return the current line count into longword lines.


4

SDA$EXTEND_HANDLER



&A callback to SDA's condition handler.



Format

,

SDA$EXTEND_HANDLER sigarg, mecharg




RETURNS



0This callback does not return a condition value.




ARGUMENTS



sigarg


                
 VMS usage: address
type:  longword (unsigned)
access:  read only
 mechanism:  by reference

FA longword containing a pointer to the condition's signal array. This 5argument is passed to your handler as first argument.

mecharg


                
 VMS usage: address
type:  longword (unsigned)
access:  read only
 mechanism:  by reference

DA longword containing a pointer to the condition's mechanism array. ;This argument is passed to your handler as second argument.



DESCRIPTION

HThis callback provides a way to invoke SDA's condition handler. You can Heither establish it as default condition handler or invoke it from your Hown handler. This may be useful if you must take special action in case Fof a condition, but let SDA perform the standard condition processing D(including the display of error messages). In your handler, you may Ftake all required actions and invoke SDA$EXTEND_HANDLER as last step. CSince SDA establishes this handler as default, you may also simply hresignal the condition (see Section 3.5 for an example).

&SDA$EXTEND_HANDLER behaves as follows:



?SDA establishes this handler by default before it invokes your @extension. If you do not want to take further action in case of Fconditions, there is no need to establish any handler again from your Dextension. All conditions signaled by your extension are trapped by ?SDA's handler which behaves in the same way as with conditions generated by SDA.





Note

ASDA$EXTEND_HANDLER invokes SYS$PUTMSG to display error messages. =Therefore, you must invoke it from executive or kernel mode. 


/

Condition values returned

2



Example


#lib$establish(SDA$EXTEND_HANDLER);  


GThis will establish SDA's condition handler in your code. By doing so, =you change the handlers behaviour in case of error and fatal Econditions: in case of error, control is not longer returned to SDA, ?instead, it is passed to the procedure wherein the handler was Gestablished. When a fatal condition occurs, SDA not longer terminates; Finstead your extension terminates only, and control is passed back to SDA.


;

SDA$EXTEND_LIB$INS_DECODE



!Decodes Alpha 21x64 instructions.



Format

C

SDA$EXTEND_LIB$INS_DECODE inadr, retbuf, retlen, [symrtn]




RETURNS

                
 VMS usage:  cond_value
type:  longword (unsigned)
access:  write only
 mechanism:  by value



ARGUMENTS



inadr


                
 VMS usage: address
type:  longword (unsigned)
access: modify
 mechanism:  by reference

FAddress of a longword pointing to the instruction to be decoded. This Eaddress must be longword-aligned. It is updated to point to the next Ainstruction before the callback returns. This allows you to call FSDA$EXTEND_LIB$INS_DECODE from within a loop without manually setting inadr.

retbuf


                
 VMS usage:  char_string
type:  character string
access:  write only
 mechanism: 4 by descriptor - fixed-length string descriptor

ABuffer to receive the decoded assembler instruction string. This Eargument is the address of a character string descriptor pointing to Hthe buffer which receives the decoded assembler instruction. The buffer Fshould provide at least 40 bytes of space; if you use a symbolization !routine, you may need more space.

retlen


                
 VMS usage: address
type:  longword (unsigned)
access:  write only
 mechanism:  by reference

EAddress of a longword receiving the length of the string returned in retbuf.

symrtn


                
 VMS usage:  procedure
type:  procedure value
access: " call without stack unwinding
 mechanism:  by reference

ASymbolization routine address. The symrtn argument is a Dlongword holding this address. The symbolization routine is used to Fsymbolize offsets (displacements) in instructions with memory-operand Eor branch-operand format. See section Symbolization routine below.



DESCRIPTION

DThis callback translates Alpha 21x64 opcodes into the corresponding Gassembler (MACRO-64) instructions. SDA invokes the callback internally Fwith the EXAMINE/INSTRUCTION command; you can use it Din your extension to translate instructions at particular addresses.

HWhen translating PAL function codes, note that only function codes used @by OpenVMS are recognized; PAL function codes used by DEC OSF/1 0(Digital UNIX) and Windows NT are not processed.





Note

FThis callback performs no memory checks at the address given Gin inadr. Before you invoke the callback, you must use one of GSDA's memory access routines to ensure that you can read the opcode at =the given address. You should first copy the entire block of Cinstructions you want to translate into a user-supplied buffer and Atranslate instructions from this buffer only. This is especially Cimportant when analyzing the running system since some code may be Cprotected against user mode, resulting in an access violation when /trying to decode it.



HThis routine exists on Alpha only, there is no replacement on VAX. Note Gthat this routine can decode Alpha 21x64 (MACRO-64) instructions only; 1you cannot use it to decode VAX MACRO-32 opcodes.

&Symbolization routine

?To symbolize displacements in branch-operand or memory-operand Ginstructions, the callback provides the symrtn argument. This >is the address of a user-supplied symbolization routine which =translates 16- or 21-bit signed displacements (offsets) into {corresponding symbol names. You may first invoke SDA$EXTEND_ADD_SYMBOL or ºSDA$EXTEND_READ_SYMFILE to define and read symbols, and later SDA$EXTEND_SYMBOLIZE in Ethe symbolization routine to show displacement values by their names.




9Previous- | Next6 | Contents