PROCEDURE dum$display_fde_table, display_fde_table, disfdet (
  address, a: integer 0..$max_integer = $optional
  residence, r: key
      (system, s), (job, j)
    keyend = $optional
  display_option, do: key
      (brief, b), (full, f)
    keyend = brief
  output, o: file = $output
  help, h: file = $null
  status)


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

  WHEN any_fault DO
    when_status = $previous_status
    putl ' Invoked DISFDET 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='disfdet_ch'
  WHENEND

  IF $specified(help) THEN
COLLECT_TEXT o=help until='HELPEND'
DISPLAY_FDET or DISFDET

  This procedure will display the file descriptor entry at the addres passed
to it.  This procedure assumes the user has previously selected the correct
exchange package by available analyze_dump commands.

PARAMETERS:

ADDRESS, A: integer
  This parameter specifies the address of the FDE table to be displayed.
Either this parameter, or the following parameter must be specified.

RESIDENCE, r: key system
  This parameter specifies the residence of the FDE table to be displayed.
If SYSTEM is specified, the FDE table in mainframe wired will be displayed;
if JOB is specified, the FDE table in job-fixed will be displayed.
Either this parameter, or the preceding parameter must be specified.

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 DISXXX 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"
NOTE: XXX is the name of the procedure in effect at the time of the error.

HELPEND
    EXIT_PROC
  IFEND

  IF (NOT $specified(address)) AND (NOT $specified(residence)) THEN
    EXIT_PROC WITH $status(false, 'US', 0, 'Must specify either address or residence')
  ELSEIF $specified(address) AND $specified(residence) THEN
    EXIT_PROC WITH $status(false, 'US', 0, 'Cannot specify both address and residence')
  IFEND

  "$FORMAT=OFF"
  VAR
    output_file: file
  VAREND

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

  "$FORMAT=OFF"
  VAR
    gfc$fde_size: integer = $mem($sa(gfv$fde_size) 8)
    gfc$fde_table_base: integer = $mem($sa(gfv$fde_table_base) 8)
    gfc$max_file_descriptor_index: integer = 0ffff(16) "maximum value of gft$file_descriptor_index"
    current_fde_entry: integer
    fde_index: integer = 0
    local_status: status
  VAREND
  "$FORMAT=ON"

  IF $specified(residence) THEN
    IF residence = 'SYSTEM' THEN
      putl ' SYSTEM FILE TABLE ' o=output_file
      current_fde_entry = 100000000(16) + gfc$fde_table_base
    ELSE
      putl ' JOB - SYSTEM FILE TABLE ' o=output_file
      current_fde_entry = 300000000(16) + gfc$fde_table_base
    IFEND
  ELSE
    current_fde_entry = address
  IFEND

  local_status.normal = true
  put_line ' FILE DESCRIPTOR TABLE: address = '//$strrep(current_fde_entry, 16)//'(16)' o=output_file
  FOR fde_index = 0 TO gfc$max_file_descriptor_index DO
    putl ' ' o=output_file
    putl ' ' o=output_file
    putl ' FDE index '//$strrep(fde_index 16)//'(16)' o=output_file
    putl ' FDE contents follows:' o=output_file
    display_fde current_fde_entry+gfc$fde_size*fde_index output=output display_option=display_option ..
          status=local_status
    IF NOT local_status.normal THEN
      disv local_status o=output_file
      putl ' Display_FDE_Table encountered abnormal status in the call to Display_FDE:'
      disv local_status
      putl ' Enter commands, "exit_proc" to abort, or "exit_proc with local_status" to abort with status'
      include_file command prompt='disfdte_ch'
    IFEND
  FOREND

PROCEND dum$display_fde_table
