ack/util/grind/grind.1

397 lines
11 KiB
Groff
Raw Normal View History

1990-09-21 16:58:20 +00:00
.\" $Header$
.TH GRIND 1
1990-09-21 16:58:20 +00:00
.SH NAME
grind \- source-level debugger for ACK
.SH SYNOPSIS
.B grind
[
.I <ACK object file>
]
[
.I <object file>
]
.SH DESCRIPTION
.B Grind
is a utility for source-level debugging and execution of
1990-09-25 17:40:47 +00:00
programs written in C, Modula-2, or Pascal.
1990-09-21 16:58:20 +00:00
Its operation resembles the operation of
.IR dbx ,
a source-level debugger
available on many Unix systems. However, some
1990-09-25 17:40:47 +00:00
.B grind
1990-09-21 16:58:20 +00:00
commands are not available in
.IR dbx ,
some
1990-09-21 16:58:20 +00:00
.I dbx
commands are not available in
.BR grind ,
and some things are just different.
1990-09-21 16:58:20 +00:00
.LP
.I <object file>
is an object file, produced by
.IR ack (1)
1990-09-21 16:58:20 +00:00
with the
.B \-g
option to include a symbol table.
.LP
If no
.I <object file>
is specified, "a.out" is used.
.LP
For some machines, the debugger does not recognize the object file
format. For these machines, the result of the
.IR led (6)
1990-09-21 16:58:20 +00:00
program must be saved and offered to
.BR grind .
.SH USAGE
Some
.B grind
commands take an expression argument.
.SS Expressions
1990-09-25 17:40:47 +00:00
.B Grind
expressions are combinations of variables, constants, and operators.
1990-09-21 16:58:20 +00:00
The syntax and the operators depend on the source language of the program
being debugged. However, the type rules are probably less strict than the
rules of this language. For instance, in Modula-2 one cannot combine
values of type INTEGER with values of type REAL in an expression without
using conversion routines. In
.BR grind ,
the conversions needed are performed automatically.
.SS Operators
.LP
.B Grind
supports operators for addition, subtraction, multiplication, division,
remainder, bitwise or, bitwise xor, bitwise and, boolean or,
boolean and, left-shift, right-shift, address-of, dereference, less than,
less than or equal, equal, not equal, greater than, greater than or equal,
selection.
.LP
The syntax and priority of these operators depends on the source language.
Parentheses can be used for grouping.
.SS "Scope Rules"
.LP
1990-09-25 17:40:47 +00:00
.B Grind
1990-09-21 16:58:20 +00:00
uses the current file and function to resolve scope conflicts.
Their values are updated as files and functions are entered and exited
during execution.
Names can also be qualified with procedure- or module names, as in
1990-11-07 15:25:24 +00:00
\fImodule\fP`\fIprocedure\fP`\fIname\fP.
1990-09-21 16:58:20 +00:00
.B Grind
1990-09-25 17:40:47 +00:00
tries to be intelligent about names; qualification is only needed when
1990-09-21 16:58:20 +00:00
names are used for more than one object in a program and the current scope
does not help.
.SS "Positions"
In general, there are two ways to specify a position; the first way is
1990-09-25 17:40:47 +00:00
to specify file name and line number, in a so-called at-clause, like this:
1990-09-21 16:58:20 +00:00
.RS
\fBat\fP [ "\fIfilename\fP": ] \fIlinenumber\fP
.RE
The
.I filename
part is optional.
The second way is to specify a function name, like this:
.RS
\fBin \fIfunction\fP
.RE
This indicates the first statement within the named function (except for
the trace command discussed later).
1990-11-07 15:25:24 +00:00
The following way is also accepted:
.RS
\fBat\fP [ "\fIfilename\fP": ] \fIlinenumber\fP \fBin \fIfunction\fP
.RE
In this case, consistency of the information given is checked. This last
form is useful for "stuffing" output from the status command described later.
1990-09-21 16:58:20 +00:00
.SS "Commands"
.TP
1990-09-25 17:40:47 +00:00
.B ^C
1990-09-21 16:58:20 +00:00
Interrupt. Stop the program being debugged and enter
.BR grind .
.TP
\fBrun\fP [ \fIargs\fP ] [ < \fIinfile\fP ] [ > \fIoutfile\fP ]
Start executing
.I <object file>
with command line arguments
.IR args ,
and possible redirection of standard input and/or standard output.
.TP
.B rerun
Repeats the last
.B run
command.
1990-09-25 17:40:47 +00:00
.TP
1990-11-07 15:25:24 +00:00
.B "rerun ?"
Prints the last
.B run
command.
.TP
\fBcont\fP [ \fIcount\fP ] [ \fBat\fP \fIsourceline\fP ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBc\fP [ \fIcount\fP ] [ \fBat\fP \fIsourceline\fP ]
1990-09-25 17:40:47 +00:00
.br
1990-09-21 16:58:20 +00:00
Continue execution from where it stopped, or, if \fIsourceline\fP is
1990-11-07 15:25:24 +00:00
given, at that source line. If \fIcount\fP is given, pass \fIcount\fP-1
breakpoints.
1990-09-21 16:58:20 +00:00
.TP
\fBtrace\fP [ \fBon\fP \fIexpression\fP ] [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
\fBt\fP [ \fBon\fP \fIexpression\fP ] [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ]
.br
1990-09-21 16:58:20 +00:00
Display tracing information.
If no argument is specified, each source line is displayed before
execution.
In addition, if an \fBon\fP-clause is given, the value of the expression
is printed.
If a position is given there are two possibilities: if the position is
given as \fBin\fP \fIfunction\fP, then the tracing information is
displayed only while executing the function or
procedure
.IR function .
If the position is given as \fBat\fP \fIlinenumber\fP,
then the tracing information is displayed only whenever the source line
indicated is reached.
1990-11-07 15:25:24 +00:00
If the position is given as \fBat\fP \fIlinenumber\fP \fBin\fP \fIfunction\fP,
the behavior is as if it was given as \fBat\fP \fIlinenumber\fP.
1990-09-21 16:58:20 +00:00
If a condition is given, tracing information is only displayed when
.I condition
is true.
.TP
\fBstop\fP [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ]
Stop execution when the
.I position
is reached, and then when
.I condition
becomes true.
If no position is given, stop when
.I condition
becomes true.
If no condition is given, stop when
.I position
is reached.
Either a position or a condition (or both) must be given.
.TP
\fBwhen\fP [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ] { \fIcommand\fP [ ; \fIcommand ] ... }
Execute the
.B grind
.IR command (s)
when the
.I position
is reached, and then when
.I condition
becomes true.
If no position is given, do this when
1990-09-21 16:58:20 +00:00
.I condition
becomes true.
If no condition is given, do this when
1990-09-21 16:58:20 +00:00
.I position
is reached.
Either a position or a condition (or both) must be given.
.TP
1990-11-07 15:25:24 +00:00
\fBprint\fP [ \fIexpression\fP [ , \fIexpression\fP ] ... ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBp\fP [ \fIexpression\fP [ , \fIexpression\fP ] ... ]
1990-09-25 17:40:47 +00:00
.br
1990-11-07 15:25:24 +00:00
Print the value of each expression. If no argument is given, repeat the
last
.B print
command.
1990-09-21 16:58:20 +00:00
.TP
1990-09-25 17:40:47 +00:00
\fBdisplay\fP \fIexpression\fP [ , \fIexpression\fP ] ...
1990-09-21 16:58:20 +00:00
Print the value of each expression whenever the program stops.
.TP
.B dump
Saves the data (global data + stack) of the program. These data can
be restore with the
.B restore
command discussed later.
.B Dump
and
.B restore
combinations can be used as a poor man's implementation of an "undo"
facility.
.TP
.B status
Display active
.BR trace ,
.BR stop ,
.BR when ,
and
.B display
commands, and associated command numbers.
Also display current
.B dump
records.
.TP
1990-11-07 15:25:24 +00:00
\fBdelete\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBd\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
1990-09-25 17:40:47 +00:00
.br
1990-11-07 15:25:24 +00:00
Remove the commands corresponding to the \fIcommandnumber\fP's given
1990-09-21 16:58:20 +00:00
(as displayed by
.BR status ).
1990-11-07 15:25:24 +00:00
If no argument is given and there is a "current" breakpoint, remove that
breakpoint.
1990-09-21 16:58:20 +00:00
.TP
1990-11-07 15:25:24 +00:00
\fBrestore\fP [ \fIcommandnumber\fP ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBr\fP [ \fIcommandnumber\fP ]
1990-09-25 17:40:47 +00:00
.br
1990-09-21 16:58:20 +00:00
Restore the data corresponding to the dump of \fIcommandnumber\fP
(as displayed by
.BR status ).
This restores the values of all variables of the program to the values
at the time the dump was made. The program counter is also restored.
This effectively puts the program back into the state it was when the
dump was made, except for file-handling: the state of the files that
the program handles is not changed.
Apart from this,
.B restore
even works when the program is finished.
1990-11-07 15:25:24 +00:00
If no \fIcommandnumber\fP is given, the last dump is restored.
1990-09-21 16:58:20 +00:00
.TP
\fBstep\fP [ \fIn\fP ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
\fBs\fP [ \fIn\fP ]
.br
1990-09-21 16:58:20 +00:00
Execute the next
.I n
source lines.
If omitted,
.I n
is taken to be 1.
This command steps into functions.
.TP
\fBnext\fP [ \fIn\fP ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
\fBn\fP [ \fIn\fP ]
.br
1990-09-21 16:58:20 +00:00
Execute the next
.I n
source lines.
If omitted,
.I n
is taken to be 1.
.B Next
steps past function-calls.
.TP
\fBwhich\fP \fIname\fP
Print the fully-qualified name of the given name.
.TP
\fBfind\fP \fIname\fP
Print the fully qualified name of all symbols matching
.IR name .
.TP
\fBset\fP \fIexpression\fP \fBto\fP \fIexpression\fP
Assign the value of the second
.I expression
to the designator indicated by the first
.IR expression .
Needless to say, the first
.I expression
must indicate a designator (something that can be assigned to).
If the types do not match,
.B grind
tries to apply conversions.
.TP
1990-11-07 15:25:24 +00:00
\fBwhere\fP [ \fIn\fP | -\fIn\fP ]
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBw\fP [ \fIn\fP | -\fIn\fP ]
.br
1990-09-21 16:58:20 +00:00
List all, or the top
.IR n ,
1990-11-07 15:25:24 +00:00
or the bottom
.IR n ,
1990-09-21 16:58:20 +00:00
active functions on the stack.
.TP
\fBfile\fP [ \fIfilename\fP ]
Print the name of the current source file, or
change the current source file to
.IR filename .
.TP
1990-11-07 15:25:24 +00:00
\fBlist\fP [ \fIstartline\fP | \fIfunction\fP ] [ , \fIcount\fP | - [ \fIendline\fP ] ]
1990-09-25 17:40:47 +00:00
.ti -0.5i
1990-11-07 15:25:24 +00:00
\fBl\fP [ \fIstartline\fP | \fIfunction\fP ] [ , \fIcount\fP | - [ \fIendline\fP ] ]
1990-09-25 17:40:47 +00:00
.br
1990-11-07 15:25:24 +00:00
If no arguments are given, list the next \fIws\fP (default 10) lines from current source file,
1990-09-21 16:58:20 +00:00
if a
.I startline
is given, list from
1990-11-07 15:25:24 +00:00
.IR startline ,
if a
.I function
is given, list from the first statement of
1990-09-21 16:58:20 +00:00
.IR function .
1990-11-07 15:25:24 +00:00
If a \fIcount\fP is given, list \fIcount\fP lines and set \fIws\fP to \fIcount\fP.
If an \fIendline\fP is given, list up until this line; if a - is given without
an \fIendline\fP, list up until the end of the file.
.TP
\fBhelp\fP [ \fIcommand\fP ]
.ti -0.5i
\fB?\fP [ \fIcommand\fP ]
.br
Print a summary of \fBgrind\fP commands, or print a message explaining
\fIcommand\fP.
.TP
\fBsource\fP \fIfilename\fP
.br
Read and execute \fBgrind\fP commands from \fIfilename\fP. This is useful for
executing \fBgrind\fP log files created with the \fBlog\fP command.
.TP
\fBlog\fP [ \fIfilename\fP | off ]
.br
Start logging the \fBgrind\fP commands given on file \fIfilename\fP, or
stop logging. If no argument is given, the current log file is printed.
.TP
\fBdisable\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
.br
Disable the commands corresponding to the \fIcommandnumber\fP's given
(as displayed by
.BR status ).
If no argument is given and there is a "current" breakpoint, disable that
breakpoint.
Disabling commands keeps them in the status, but makes them inoperative.
Disabled commands can be enabled again with the \fBenable\fP command.
.TP
\fBenable\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
.br
Enable the commands corresponding to the \fIcommandnumber\fP's given
(as displayed by
.BR status ).
If no argument is given and there is a "current" breakpoint, enable that
breakpoint.
.TP
\fB!\fP \fIshellcommand\fP
.br
Invoke the shell with \fIshellcommand\fP. \fIshellcommand\fP extends to the
end of the line. In the command, the characters `%' and `!' are replaced
with the current file name and the previous shell command respectively.
The sequences `\%' and `\!' are replaced by `%' and `!' respectively.
.TP
\fBframe\fP [ \fIcount\fP | + \fIcount\fP | - \fIcount\fP ]
.br
The currently active procedure has frame number 0, the one that invoked this
one has frame number 1, etc. The \fBframe\fP command allows the user to
examine stack frames beyond the current one. For instance, after giving the
command `frame 1', variables of the frame invoking the currently active
procedure can be examined. There is a relative and an absolute version of this
command.
1990-09-21 16:58:20 +00:00
.TP
.B quit
1990-11-07 15:25:24 +00:00
.br
1990-09-21 16:58:20 +00:00
Exit
.BR grind .
1990-09-25 17:40:47 +00:00
.LP
Some commands can be repeated without arguments by entering an empty command line:
step, next, list, cont.
1990-09-21 16:58:20 +00:00
.SH SEE ALSO
.IR ack (1).
.IR led (6).
1990-09-25 17:40:47 +00:00
.SH REMARKS
1990-09-21 16:58:20 +00:00
.LP
.B Grind
1990-09-25 17:40:47 +00:00
does not understand the scope of WITH statements. The scope information needed
is not available in the symbol table.
.SH BUGS
1990-09-21 16:58:20 +00:00
.LP
.B Grind
1990-09-25 17:40:47 +00:00
does not correctly handle bit-fields.