.lf 1 tmac.an.nr
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /home2/aoki/master/ref/RCS/tmac.an.nr,v 1.1 1993/01/26 02:43:13 aoki Exp $
.ds II INGRES
.ds PG POSTGRES
.ds UU UNIX
.ds PQ POSTQUEL
.ds LI LIBPQ
.ds PV 4.1
.de (l 			\" fake "-me"-style lists
.nf
.ie '\\$1'M' .in +0n
.el .in +5n
..
.de )l
.fi
.in
..
.de (C			\" constant-width font blocks
.(l \\$1
.sp
..
.de )C
.sp
.)l
..
.de BH			\" reference manual "big header" for sections
.SH NAME
\&\\$1
..
.de SB			\" section/index stuff
..	\" no-op
.de SE
..	\" no-op
.de XA
..	\" no-op
.de XP
..	\" no-op
.de SP
..
.ds lq ""
.ds rq ""
.lf 1 unix/shmemdoc.1src
.\" This is -*-nroff-*-
.\" $Header: /home2/aoki/master/ref/unix/RCS/shmemdoc.1src,v 1.3 1993/01/26 02:43:13 aoki Exp $
.TH SHMEMDOC UNIX 01/23/93
.XA 1 "Shmemdoc"
.SH NAME
shmemdoc \(em \*(PG shared memory editor
.SH SYNOPSIS
.BR shmemdoc
[\c
.BR -p
port]
[\c
.BR -B
nbuffers]
.SH DESCRIPTION
The
.BR shmemdoc
program understands the layout of \*(PG data in shared memory and can
be used to examine these shared structures.  This program is intended
only for debugging \*(PG, and should not be used in normal operation.
.PP
When some backend server dies abnormally, the postmaster normally
reinitializes shared memory and semaphores and forces all peers of the
dead process to exit.  If
.IR postmaster
is started with the 
.BR -n
flag, then shared memory will not be reinitialized and
.BR shmemdoc
can be used to examine shared state after the crash.
.PP
.IR Shmemdoc
understands the following command-line options:
.TP 5n
.BR "-B" " nbuffers"
The number of buffers used by the backend.  This value is ignored in
the present implementation of
.IR shmemdoc ,
but is important if you choose to change the number allocated by
\*(PG.  In that case, you're out of luck for now.
.TP
.BR "-p" " port"
The port on which the postmaster was listening.
This value is used to compute the shared memory key used by the
postmaster when shared memory was initialized.
.PP
A simple command interpreter reads user commands from standard input
and prints results on standard output.  The available commands are:
.TP 5n
.BR "semstat"
Show the status of system semaphores.  Status includes semaphore names
and values, the process id of the last process to change each
semaphore, and a count of processes sleeping on each semaphore.
.TP
.BI "semset" " n val"
Set the value of semaphore number
.IR n
(with zero being the first semaphore named by
.BR semstat )
to
.IR val .
This is really only useful for resetting system state manually after a
crash, which is something you don't really want to do.
.TP
.BI "bufdescs"
Print the contents of the shared buffer descriptor table.
.TP
.BI "bufdesc" " n"
Print the shared buffer descriptor table entry for buffer
.IR n .
.TP
.BI "buffer" " n type level"
Print the contents of buffer number
.IR n
in the shared buffer table.  The buffer is interpreted as a page from
a
.IR type
relation,
where
.IR type
may be
.IR heap ,
.IR btree ,
or
.IR rtree .
The
.IR level
argument controls the amount of detail presented.  Level zero prints
only page headers, level one prints page headers and line pointer
tables, and level two (or higher) prints headers, line pointer tables,
and tuples.
.TP
.BI "linp" " n which"
Print line pointer table entry
.IR which
of buffer
.IR n .
.TP
.BI "tuple" " n type which"
Print tuple
.IR which
of buffer
.IR n .
The buffer is interpreted as a page from a
.IR type
relation,
where
.IR type
may be
.IR heap ,
.IR btree ,
or
.IR rtree .
.TP
.BI "setbase" " ptr"
Set the logical base address of shared memory for
.IR shmemdoc
to
.IR ptr .
Normally,
.IR shmemdoc
uses the address of each structure in its own address space when
interpreting commands and printing results.  If
.IR setbase
is used, then on input and output, addresses are translated so that
the shared memory segment appears to start at address
.IR ptr .
This is useful when a debugger is examining a core file produced by
\*(PG and you want to use the shared memory addresses that appear in
the core file.  The base of shared memory in \*(PG is stored in the
variable
.IR ShmemBase ,
which may be examined by a debugger.
.IR Ptr
may be expressed in octal (leading zero),
decimal,
or hexadecimal
(leading 0x).
.TP
.BI "shmemstat"
Print shared memory layout and allocation statistics.
.TP
.BI "whatis" " ptr"
Identify the shared memory structure pointed at by
.IR ptr .
.TP
.BI "help"
Print a brief command summary.
.TP
.BI "quit"
Exit
.IR shmemdoc .
.SH "SEE ALSO"
ipcclean(unix).
.SH BUGS
Probably doesn't work on anything but DECstations.
.PP
All of the sizes, offsets, and values for shared data are hardwired
into this program; it shares no code with the ordinary \*(PG system,
so changes to shared memory layout will require changes to this
program, as well.
