PROCEDURE dum$display_server_file_desc, display_server_file_desc, display_sfd (
  pva: integer = $optional
  output, o: file = $output
  display_option, do: key
      (brief, b), (full, f)
    keyend = brief
  help, h: file = $null
  status)


  "$FORMAT=OFF"
  VAR
    when_status: status
  VAREND
  "$FORMAT=ON"

  WHEN any_fault DO
    when_status = $previous_status
    putl ' Invoked DISPLAY_SFD condition handler due to the following abnormal status:'
    disv when_status
    putl ' Enter commands, "exit_proc" to abort, or "exit_proc with when_status" to abort with status'
    include_file command prompt='display_sfd_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_SERVER_FILE_DESC or DISPLAY_SFD

  This procedure will display a served file's server file descriptor when
given a process virtual address to the entry.  This procedure assumes the
user has selected the correct exchange package by available analyze_dump
commands.

PARAMETERS:

PVA: integer
  This parameter passes the processor virtual address of the served file
descriptor to be displayed.  This parameter is required.

OUTPUT, O: file
  This parameter selects the file name to receive the data.  This para-
meter is defaulted to $output.  If a file name other than $output is
entered the data will be formated correctly for printer disposition and
will be sent to the file  "$asis".

DISPLAY_OPTIONS, DO: key full, f, brief, b
  This parameter selects the option of displaying the contents of memory
and the description of the selected fields (full), or the brief mode of
the descriptions only.  This parameter defaults to brief.

STATUS

WARNINGS/KNOWN DEFICIENCIES:

ERROR HANDLER
  When any fatal error is encountered a condition handler is invoked and
the following messages will appear:
 "Invoked DISPLAY_SFD condition handler due to the following abnormal status:"
 "< the error status message >"
 "Enter commands, "exit_proc" to abort, or "exit_proc with when_status"
  to abort with status"
To exit the handler enter:    "exit_proc"
To exit the handler with status, enter:   "exit_proc with when_status"

HELPEND
    EXIT_PROC
  IFEND

  IF NOT $specified(pva) THEN
    EXIT_PROC WITH $status(false, 'US', 6, 'Parameter PVA is required')
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file

" The following offsets were obtained from the output of the command Display_Symbol_Table
" for the type DFT$SERVER_DESCRIPTOR.

    server_mainframe_id_offset: integer = 0(16)
      model_number_offset: integer = 0(16)
      serial_number_offset: integer = 1(16)
    served_family_tbl_index_offset: integer = 3(16)
      pointers_index_offset: integer = 0(16)
      family_list_index_offset: integer = 1(16)
    server_lifetime_offset: integer = 5(16)
    read_write_count_offset: integer = 7(16)
    purged_offset: integer = 9(16)
    highest_offset_allocated_offset: integer = 0a(16)
    bytes_per_allocation_offset: integer = 10(16)
    dft$server_state: array 0..6 of string 1..$max_name = ('dfc$active', 'dfc$deactivated', 'dfc$inactive', ..
          'dfc$awaiting_recovery', 'dfc$recovering', 'dfc$terminated', 'dfc$deleted')
    file_state_offset: integer = 13(16)

" Variant for file_state = DFC$ACTIVE:

      total_allocated_length_offset: integer = 14(16)
      remote_sfid_offset: integer = 1a(16)
      allow_other_mf_write_offset: integer = 1e(16)
      allocation_info_offset: integer = 1f(16)
        server_allocation_needed_offset: integer = 0(16)

" Variant for server_allocation_needed = FALSE:

          invalid_data_offset: integer = 1(16)

" Variant for server_allocation_needed_offset = TRUE:

          bytes_to_allocate_offset: integer = 1(16)
      requested_transfer_size_offset: integer = 26(16)

" Variant for file_state = DFC$AWAITING_RECOVERY, DFC$TERMINATED: None

  VAREND
  "$FORMAT=ON"

  IF $file(output open_position) = '$BOI' THEN
    output_file = output.$asis
  ELSE
    output_file = output
  IFEND

  IF output = :$local.$output THEN
    putl '1SERVER FILE DESCRIPTOR ' o=output_file
  IFEND

  IF display_option = 'FULL' THEN
    display_memory pva bytes=29(16) t='SERVER FILE DESCRIPTOR' o=output_file
  IFEND

  start_of_sfd = pva
  putl '   ' o=output_file

  putl ' server_mainframe_id:' o=output_file
  putl '   model_number = '//..
$strrep($mem(start_of_sfd+server_mainframe_id_offset+model_number_offset, 1) 16)//'(16)' o=output_file
  putl '   serial_number = '//..
$strrep($mem(start_of_sfd+server_mainframe_id_offset+serial_number_offset, 2) 16)//'(16)' ..
        o=output_file

  putl ' served_family_table_index:' o=output_file
  putl '   pointers_index = '//..
$strrep($mem(start_of_sfd+served_family_tbl_index_offset+pointers_index_offset, 1) 16)//'(16)' ..
        o=output_file
  putl '   family_list_index = '//..
$strrep($mem(start_of_sfd+served_family_tbl_index_offset+family_list_index_offset, 1) 16)//'(16)' ..
        o=output_file

  putl ' server_lifetime = '//$strrep($mem(start_of_sfd+server_lifetime_offset 2) 16)//'(16)' ..
        o=output_file

  putl ' read_write_count = '//$strrep($mem(start_of_sfd+read_write_count_offset 2) 16)//'(16)' ..
        o=output_file

  IF $mem(start_of_sfd+purged_offset, 1) = 1 THEN
    putl ' purged = TRUE' o=output_file
  ELSE
    putl ' purged = FALSE' o=output_file
  IFEND

  putl ' highest_offset_allocated = '//..
$strrep($mem(start_of_sfd+highest_offset_allocated_offset 6) 16)//'(16)' o=output_file

  putl ' bytes_per_allocation = '//$strrep($mem(start_of_sfd+bytes_per_allocation_offset 3) 16)//'(16)' ..
        o=output_file

  file_state = dft$server_state($mem(start_of_sfd+file_state_offset 1))
  putl ' file_state = '//file_state o=output_file

  IF file_state = 'dfc$active' THEN
    putl '   total_allocated_length = '//..
$strrep($mem(start_of_sfd+total_allocated_length_offset 6) 16)//'(16)' o=output_file

    putl '   remote_sfid = '//$strrep($mem(start_of_sfd+remote_sfid_offset 4) 16)//'(16)' ..
          o=output_file

    IF $mem(start_of_sfd+allow_other_mf_write_offset, 1) = 1 THEN
      putl '   allow_other_mainframe_writer = TRUE' o=output_file
    ELSE
      putl '   allow_other_mainframe_writer = FALSE' o=output_file
    IFEND

    putl '   allocation_info:' o=output_file
    IF $mem(start_of_sfd+allocation_info_offset+server_allocation_needed_offset, 1) = 1 THEN
      putl '     server_allocation_needed = TRUE' o=output_file
      putl '       bytes_to_allocate = '//..
$strrep($mem(start_of_sfd+allocation_info_offset+bytes_to_allocate_offset, 6) 16)//'(16)' ..
            o=output_file
    ELSE
      putl '     server_allocation_needed = FALSE' o=output_file
      putl '       invalid_data = '//..
$strrep($mem(start_of_sfd+allocation_info_offset+invalid_data_offset, 6) 16)//'(16)' o=output_file
    IFEND

    putl '   requested_transfer_size = '//..
$strrep($mem(start_of_sfd+requested_transfer_size_offset 3) 16)//'(16)' o=output_file
  IFEND

PROCEND dum$display_server_file_desc
