[comp.sys.ibm.pc.rt] Fix for dbx, part 1 of 5, IBM/4.3

brunner@bullhead.uucp (10/21/89)

Subject: Fix for dbx (part 1)
Index: /usr/src/ucb/dbx IBM/4.3

Description:
	Several problems (too numerous to mention) exist
	with the December release of dbx. This is part 1 
	of a 5 part patch installation kit. The contents
	of the kit are:

part 1	shar file containing help.c
part 2	patchs to the following files:
	dbx/ibmrt/{coredump.c,decode.c,frame.c,procinfo.c}
part 3	patchs to the following files:
	dbx/{object.c,eval.c,commands.y,c.c,tree.c}
part 4	patchs to the following files:
	dbx/{runtime.c,symbols.c,execute.c,events.c,mappings.c}
part 5	patches to the following files:
	dbx/{stabstring.c,printsym.c,operators.c,process.c,
	     keywords.c,pascal.c,fortran.c,main.c,Makefile,
	     examine.c,scanner.c,source.c,library.c}


Fix:	Change directories to /usr/src/ucb/dbx and unpack
	the attached shar file, e.g.,

		sh < this_file

	This will create the new help.c file. Proceede to
	the next part of the kit.

	Inconsistencies between the several compilers (hc,
	pp, f77) and the loader exist, stabs in particular.
	These will be corrected in a following patch to dbx,
	or in corrective releases of the compilers, or both.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	help.c
#
echo x - help.c
sed 's/^X//' >help.c << 'END-of-help.c'
X/* help.c -- online help for dbx */
X
X#include "defs.h"
X#include "tree.h"
X#include "symbols.h"
X#include "keywords.h"
X#include "process.h"
X#include "runtime.h"
X#include "source.h"
X#include "object.h"
X#include "mappings.h"
X#include "y.tab.h"
X
Xstatic String help_commands[] ={
X    "alias", "assign", "call",
X    "catch", "clear", "cleari", "cont", "debug", "delete", /*"detach", */
X    "down", "dump", "edit", "file", "func", "goto", "gotoi", 
X#ifdef	MAINTAINER
X    "gripe",
X#endif	/* MAINTAINER */
X    "help", "ignore", "list", "listi", /*"multproc",*/
X    "next", "nexti", "print", /*"prompt",*/ "psym", "quit",
X    "registers", "rerun", "return", "run", /*"screen",*/ "set", "sh", 
X    "source", "status", "step", "stepi", "stop", "stopi", "trace",
X    "tracei", "unalias", "unset", "up", "use", /*"watch",*/ "whatis", "when",
X    "where", "whereis", "which", /*"wins", "wini",*/ 0
X};
X
Xstatic String help_topics[] = {
X   "execution", "expressions", 
X   "files", "printing", 
X   "usage", "variables",
X   0
X};
X
Xstatic void
Xhelp_help()
X{
X   String *p;
X   int len, i;
X
X   puts("Commands:");
X   i = len = 0;
X   for ( p = help_commands; *p; p++ ){
X      printf(" %s ",*p);
X      i = strlen(*p); /* there is a bug in printf!! on the RT */
X      while ( i++ < 11 )	
X	printf(" ");
X      len += 11;
X      if ( len >= 65 ){
X	 printf("\n");
X	 len = 0;
X      }
X   }
X   puts("\nTopics:");
X   for ( p = help_topics; *p; p++ ){
X      printf(" %s ",*p);
X   }
X   puts("\n\nType \"help <command>\" or \"help <topic>\" for help on a command or topic.\n");
X}
X
X/*
X * help_topic:
X * See if the user wants help on a given topic
X */
X
Xprivate help_topic(s)
X   char *s;
X{
X   if ( !strncmp(s,"exe",3) ){
X      puts("Execution controlling commands:");
X      puts("See: run, rerun, stop, status, catch, ignore, cont");
X      puts("step, next, return and call commands.");
X   }
X   else if ( !strncmp(s,"exp",3) ){
X      puts("Expressions are specified with an approximately common");
X      puts("subset of C and Pascal syntax. Indirection can be denoted");
X      puts("using either a prefix \"*\" or a postfix \"^\" and array");
X      puts("expressions are subscripted by brackets (\"[\" \"]\"). The");
X      puts("field reference operator (\".\") can be used with pointers");
X      puts("as well as structures, unions, and records, making the C");
X      puts("operator \"->\" unnecessary (although it is supported).");
X      puts("");
X      puts("Types of expressions are checked; the type of an expression");
X      puts("may be overridden by using \"type-name(expression)\". When");
X      puts("there is no corresponding named type the special constructs");
X      puts("\"$type-name\" and \"$$tag-name\" can be used to represent a");
X      puts("pointer to a named type or C structure tag.");
X   }
X   else if ( !strncmp(s,"fil",3) ){
X      puts("Accessing source files:");
X      puts("/<regular-expression>[/]");
X      puts("?<regular-expression>[?]");
X      puts("\tSearch (respectively) forward or backward in the current");
X      puts("\tsource file for the given <regular-expression>.");
X      puts("See also:");
X      puts("\tedit, file, func, list and use commands.");
X   }
X   else if ( !strncmp(s,"pri",3) ){
X      puts("Address level printing.");
X      puts("<address> , <address>/ [<mode>]");
X      puts("<address> / [<count>]  [<mode>]");
X      puts("\tPrint the contents of memory starting at the first");
X      puts("\t<address> up to the second <address> or until <count>");
X      puts("\titems are printed. If the address is \".\", the address");
X      puts("\tfollowing the one most recently printed is used. The mode");
X      puts("\tspecifies how memory is to be printed; if it is omitted the");
X      puts("\tprevious mode specified is used. The initial mode is \"X\".");
X      puts("\tThe following modes are supported:");
X      puts("");
X      puts("\ti   print the machine instruction");
X      puts("\td   print a short word in decimal");
X      puts("\tD   print a long word in decimal");
X      puts("\to   print a short word in octal");
X      puts("\tO   print a long word in octal");
X      puts("\tx   print a short word in hexadecimal");
X      puts("\tX   print a long word in hexadecimal");
X      puts("\tb   print a byte in octal");
X      puts("\tc   print a byte as a character");
X      puts("\ts   print a string (terminated by a null byte)");
X      puts("\tf   print a single precision real number");
X      puts("\tg   print a double precision real number");
X      puts("");
X      puts("Symbolic addresses are specified by preceding the name with");
X      puts("an \"&\". Registers are denoted by \"$rN\" where N is the");
X      puts("number of the register. Addresses may be expressions made");
X      puts("up of other addresses and the operators \"+\", \"-\", and");
X      puts("indirection ( unary \"*\").");
X   }
X   else if ( !strncmp(s,"usa",3) ){
X      puts("Basic dbx command usage:\n");
X      puts("run                    - begin execution of the program");
X      puts("print <exp>            - print the value of the expression");
X      puts("where                  - print currently active procedures");
X      puts("stop at <line>         - suspend execution at the line");
X      puts("stop in <proc>         - suspend execution when <proc> is called");
X      puts("cont                   - continue execution");
X      puts("step                   - single step one line");
X      puts("next                   - step to next line (skip over calls)");
X      puts("trace <line#>          - trace execution of the line");
X      puts("trace <proc>           - trace calls to the procedure");
X      puts("trace <var>            - trace changes to the variable");
X      puts("trace <exp> at <line#> - print <exp> when <line> is reached");
X      puts("status                 - print trace/stop's in effect");
X      puts("delete <number>        - remove trace or stop of given number");
X      puts("call <proc>            - call a procedure in program");
X      puts("whatis <name>          - print the declaration of the name");
X      puts("list <line>, <line>    - list source lines");
X      puts("registers              - display register set");
X      puts("quit                   - exit dbx");
X   }
X   else if ( !strncmp(s,"var",3) ){
X      puts("\tThe following \"set\" variables have special meanings:");
X      puts("");
X      puts("\t$frame");
X      puts("\t\tSetting this variable to an address alters dbx's");
X      puts("\t\tidea of the current stack frame.");
X      puts("");
X      puts("\t$expandunions");
X      puts("\t\tCauses dbx to display values of each part of variant");
X      puts("\t\trecords or unions.");
X      puts("");
X      puts("\t$hexchars $hexints $hexstrings");
X      puts("\t\tWhen set, dbx prints characters, integers or");
X      puts("\t\tcharacter pointers in hexadecimal.");
X      puts("");
X      puts("\t$listwindow");
X      puts("\t\tSpecifies the number of lines to list and listi commands.");
X      puts("");
X      puts("\t$mapaddrs");
X      puts("\t\tControls address mapping, useful for kernel debugging.");
X      puts("");
X      puts("\t$unsafecall $unsafeassign");
X      puts("\t\tTurn off type checking for calls and assignments.");
X   }
X   else   printf("%s is not a known help topic or command\n",s);
X}
X
Xprivate help_command(op,cmd)
X   int op;
X   char *cmd;
X{
X   switch ( op ){
X
X    case ALIAS:
X      puts("alias");
X      puts("alias <name> <name>");
X      puts("alias <name> \"<string>\"");
X      puts("alias <name> ( <parameters> ) \"<string>\"");
X      puts("\tWhen commands are processed, dbx first checks to see if");
X      puts("\tthe word is an alias for either a command or a string.");
X      puts("\tIf it is an alias, then dbx treats the input as though");
X      puts("\tthe corresponding string (with values substituted for ");
X      puts("\tany parameters) had been entered.");
X      puts("\tAlias with no arguments prints the alias definition list.");
X      break;
X
X    case ASSIGN:
X      puts("assign <variable> = <expression>");
X      puts("\tAssign the value of the expression to the variable.");
X      break;
X
X    case CALL:
X      puts("call <procedure> ( <parameters> )");
X      puts("\tExecute the object code associated with the named");
X      puts("\tprocedure or function");
X      break;
X#ifdef 0
X    case CASE:
X      puts("case");
X      puts("case mixed");
X      puts("case lower");
X      puts("case upper");
X      puts("case default");
X      puts("\tSet character case sensitivity.");
X      puts("\tCase with no arguments prints the current case sensitivity.");
X      break;
X#endif
X    case CATCH:
X    case IGNORE:
X      puts("catch <signal-number>");
X      puts("catch <signal-name>");
X      puts("ignore <signal-number>");
X      puts("ignore <signal-name>");
X      puts("\tStart or stop trapping a signal before it is sent to");
X      puts("\tthe program. This is useful when a program being");
X      puts("\tdebugged handles signals such as interrupts. A signal");
X      puts("\tmay be specified by number or name.");
X      puts("\tSignal names are by default case insensitive and the \"SIG\"");
X      puts("\tprefix is optional. By default all signals are trapped");
X      puts("\texcept SIGCONT, SIGCHILD, SIGALRM and SIGKILL.");
X      break;
X
X    case CONT:
X      puts("cont");
X      puts("cont <signal-number>");
X      puts("cont <signal-name>");
X      puts("\tContinue execution from where it stopped. If a signal");
X      puts("\tis specified, the process continues as though it");
X      puts("\treceived the signal. Otherwise, the process is continued");
X      puts("\tas though it had not been stopped.");
X      break;
X
X    case DELETE:
X      puts("delete <command-number>");
X      puts("delete all");
X      puts("\tThe traces or stops corresponding to the given numbers");
X      puts("\tare removed. The numbers associated with traces and stops");
X      puts("\tare printed with the \"status\" command.");
X      break;
X
X    case DOWN:
X    case UP:
X      puts("up");
X      puts("down");
X      puts("up <count>");
X      puts("down <count>");
X      puts("\tMove the current function, which is used for resolving");
X      puts("\tnames, up or down the stack <count> levels. The default");
X      puts("\t<count> is one.");
X      break;
X
X    case DUMP:
X      puts("dump");
X      puts("dump .");
X      puts("dump <procedure> [ > <filename> ]");
X      puts("\tPrint the names and values of variables in the given");
X      puts("\tprocedure, or the current one if none is specified. If");
X      puts("\tthe procedure given is \'.\', then all active variables");
X      puts("\tare dumped.");
X      break;
X
X    case EDIT:
X      puts("edit");
X      puts("edit <filename>");
X      puts("edit <procedure>");
X      puts("\tInvoke an editor on <filename> or the current source file");
X      puts("\tif none is specified. If a procedure or function name");
X      puts("\tis specified the editor is invoked on the file that");
X      puts("\tcontains it. Which editor is invoked by default depends");
X      puts("\ton the installation. The default can be overridden by");
X      puts("\tsetting the environment variable EDITOR to the name of");
X      puts("\tthe desired editor.");
X      break;
X
X    case FILE:
X      puts("file");
X      puts("file <filename>");
X      puts("\tChange the current source file name to <filename>. If");
X      puts("\tnone is specified then the current source file name is");
X      puts("\tprinted.");
X      break;
X
X    case FUNC:
X      puts("func");
X      puts("func <procedure>");
X      puts("\tChange the current function. If none is specified then");
X      puts("\tprint the current function. Changing the current function");
X      puts("\timplicitly changes the current source file to the");
X      puts("\tone that contains the function; it also changes the");
X      puts("\tcurrent scope used for name resolution.");
X      break;
X
X    case CLEAR:
X      puts("clear <line-number>");
X      puts("\tRemove all breakpoints at a given line number.");
X      puts("\tSee also: delete");
X      break;
X
X    case CLEARI:
X      puts("cleari <address>");
X      puts("\tRemove all breakpoints at a given address.");
X      puts("\tSee also: delete");
X      break;
X
X    case DEBUG:
X      puts("debug <number>");
X      puts("\tdbx internal debug switches");
X      break;
X
X    case GOTOI:
X    case GOTO:
X      puts("goto <line-number>");
X      puts("goto \"<filename>\" : <line-number>");
X      puts("gotoi <address>");
X      puts("\tChange the program counter to <address> or an address");
X      puts("\tnear <line-number>. The variable $unsafegoto must be set");
X      puts("\tif a goto out of the current function is desired.");
X      break;
X
X    case HELP:
X      puts("help");
X      puts("help <command>");
X      puts("help <topic>");
X      puts("\tPrint information about command or topic.");
X      break;
X
X    case LIST:
X      puts("list [ <source-line-number> [, <source-line-number> ]]");
X      puts("list <procedure>");
X      puts("\tList the lines in the current source file from the");
X      puts("\tfirst line number to the second inclusive. If no lines");
X      puts("\tare specified, the next 10 lines are listed. If the");
X      puts("\tname of a procedure or function is given lines n-k to");
X      puts("\tn+k are listed where n is the first statement in the");
X      puts("\tprocedure or function and k is defined by $listwindow");
X      break;
X
X    case LISTI:
X      puts("listi");
X      puts("listi <source-line-number>");
X      puts("listi <address>");
X      puts("listi <procedure>");
X      puts("\tList the instructions from the current program counter");
X      puts("\tlocation or given address, line number or procedure.");
X      puts("\tThe number of instructions printed is controlled by");
X      puts("\tthe dbx internal variable $listwindow.");
X      break;
X
X    case NEXT:
X      puts("next");
X      puts("\tExecute up to the next source line. The difference between");
X      puts("\tthis and \"step\" is that if the line contains a call");
X      puts("\tto a procedure or function the \"step\" command will");
X      puts("\tstop at the beginning of that block, while the \"next\"");
X      puts("\tcommand will not.");
X      break;
X
X    case NEXTI:
X      puts("nexti");
X      puts("\tSingle step as in \"next\", but do a single instruction");
X      puts("\trather than source line.");
X      break;
X
X    case PRINT:
X      puts("print <expression> [, <expression>]");
X      puts("\tNames are resolved first using the static scope of the");
X      puts("\tcurrent function, then using the dynamic scope if the name");
X      puts("\tis not defined in the static scope. If static and dynamic");
X      puts("\tsearches do not yield a result, an arbitrary symbol is");
X      puts("\tchosen and the message \"[using <qualified-name>]\" is");
X      puts("\tprinted. The name resolution procedure may be overridden by");
X      puts("\tqualifying an identifier with a block name, e.g.,");
X      puts("\t\"module.variable\". For C, source files are treated as");
X      puts("\tmodules named by the file name without \".c\"");
X      puts("");
X      break;
X#ifdef 0
X    case PROMPT:
X      puts("prompt");
X      puts("\tDisplays the dbx prompt.");
X      break;
X#endif
X    case PSYM:
X      puts("psym <name>");
X      puts("\tPrint the dbx symbol table entry for <name>.");
X      break;
X
X    case QUIT:
X      puts("quit");
X      puts("\tExit dbx.");
X      break;
X
X    case REGISTERS:
X      puts("registers");
X      puts("\tPrint the contents of all machine registers.");
X      break;
X
X    case RERUN:
X    case RUN:
X      puts("run [<arguments>] [< <filename>] [> <filename>] ");
X      puts("rerun [<arguments>] [< <filename>] [> <filename>] ");
X      puts("\tStart executing the object file, passing arguments as");
X      puts("\tcommand line arguments; < or > can be used to redirect");
X      puts("\tinput or output in a shell-like manner. When \"rerun\"");
X      puts("\tis used without any arguments the previous argument list");
X      puts("\tis passed to the program; otherwise it is identical to run.");
X      puts("\tIf the object file has been written to since the last time");
X      puts("\tthe symbolic information was read in, dbx will read in the");
X      puts("\tnew information");
X      break;
X
X    case RETURN:
X      puts("return");
X      puts("return <procedure>");
X      puts("\tContinue until a return to <procedure> is executed, or");
X      puts("\tuntil the current procedure returns if none is specified.");
X      break;
X
X    case SET:
X      puts("set <name>");
X      puts("set <name> = <expression>");
X      puts("\tThe set command defines values for dbx variables.");
X      puts("\tThe names of these variables cannot conflict with names");
X      puts("\tin the program being debugged, and are expanded to the");
X      puts("\tcorresponding expression within other commands.");
X      puts("\tSee also \"help variables\" for definitions of predefined");
X      puts("\tset variables.");
X      break;
X
X    case SH:
X      puts("sh <command-line>");
X      puts("\tPass the command line to the shell for execution.");
X      puts("\tThe SHELL environment variable determines which shell is used.");
X      break;
X
X    case SOURCE:
X      puts("source <filename>");
X      puts("\tRead dbx commands from the given file.");
X      break;
X
X    case STATUS:
X      puts("status [> <filename>]");
X      puts("\tPrint out the currently active trace and stop commands.");
X      break;
X
X    case STEP:
X      puts("step");
X      puts("\tExecute one source line.");
X      break;
X
X    case STEPI:
X      puts("stepi");
X      puts("\tExecute a single instruction");
X      break;
X
X    case STOP:
X      puts("stop if <condition>");
X      puts("stop at <line-number> [if <condition>]");
X      puts("stop in <procedure>   [if <condition>]");
X      puts("stop <variable>       [if <condition>]");
X      puts("\tStop execution when the given line is reached,");
X      puts("\tprocedure or function entered, variable changed,");
X      puts("\tor condition true.");
X      break;
X
X    case STOPI:
X      puts("stopi <address>    [if <condition>]");
X      puts("stopi at <address> [if <condition>]");
X      puts("\t\"stopi at <address>\" stops execution when the given");
X      puts("\t<address> is reached.");
X      puts("\t\"stopi <address>\" stops execution when the value located");
X      puts("\tat the given <address> changes.");
X      break;
X
X    case UNALIAS:
X      puts("unalias <name>");
X      puts("\tRemove the alias for <name>.");
X      break;
X
X    case UNSET:
X      puts("unset <name>");
X      puts("\tRemove the definition for <name>.");
X      break;
X
X    case USE:
X      puts("use <directory-list>");
X      puts("\tSet the list of directories to be searched when looking");
X      puts("\tfor source files.");
X      break;
X
X    case WHATIS:
X      puts("whatis <name>");
X      puts("\tPrint the declaration of the given name.");
X      break;
X
X    case WHERE:
X      puts("where");
X      puts("\tPrint out a stack trace of the currently active procedures");
X      puts("\tand functions.");
X      break;
X
X    case WHEREIS:
X      puts("whereis <name>");
X      puts("\tPrint the full qualification of all symbols whose name");
X      puts("\tmatches <name>.");
X      break;
X
X    case WHICH:
X      puts("which <name>");
X      puts("\tPrint the full qualification of the given <name>,");
X      puts("\ti.e the outer blocks that the name is associated with.");
X      break;
X
X    case TRACE:
X      puts("trace [in <procedure>]              [if <condition>]");
X      puts("trace <line-number>                 [if <condition>]");
X      puts("trace <procedure> [in <procedure>]  [if <condition>]");
X      puts("trace <variable>  [in <procedure>]  [if <condition>]");
X      puts("trace <expression> at <line-number> [if <condition>]");
X      puts("\tHave tracing information printed when the program is");
X      puts("\texecuted. A number is associated with the command so");
X      puts("\tthat tracing can be turned off with the delete command.");
X      break;
X
X    case TRACEI:
X      puts("tracei [<address>] [if <condition>]");
X      puts("tracei [<variable>] [at <address>] [if <condition>]");
X      puts("\tTurn on tracing using a machine instruction address.");
X      puts("See trace command.");
X      break;
X
X    case WHEN:
X      puts("when in <procedure>   { <actions> }");
X      puts("when at <line-number> { <actions> }");
X      puts("when at <address>     { <actions> }");
X      puts("when <expression>     { <actions> }");
X      puts("\tWhen <expression> is true, execute <actions>.");
X      puts("\tWhere <actions> is a list of dbx commands.");
X      break;
X#ifdef 0
X    case SCREEN:
X      puts("screen");
X      puts("\tSwitch dbx to another virtual terminal.");
X      break;
X
X    case WATCH:
X      puts("watch <expression> [if <condition>]");
X      puts("watch <expression> [in <procedure>]  [if <condition>]");
X      puts("watch <expression> [at <line-number>] [if <condition>]");
X      puts("\tSee trace command.");
X      break;
X
X    case MULTPROC:
X    case DETACH:
X    case WINS:
X    case WINI:
X      printf("%s is currently undocumented\n",cmd);
X      break;
X#endif
X    default:
X      printf("no help available for %s\n",cmd);
X   }
X   puts("");
X}
X
X/*
X * Give the user some help.
X */
X
Xpublic help(n)
X   Node n;
X{
X   Node name;
X   int op;
X
X   name = n->value.arg[0];
X
X   if ( name == nil ){
X     help_help();
X     return;
X  }
X   /* resolve aliasing first ...???
X
X   if ( findalias(name->value.name,&s1,&s2) ){
X       expand(p,str);
X   }
X
X   */
X
X   op = findkeyword(name->value.name,0);
X
X   if ( op )
X      help_command(op,ident(name->value.name));
X   else 
X      help_topic(ident(name->value.name));
X}
END-of-help.c
exit


Eric Brunner, IBM AWD Palo Alto
inet: brunner@monet.berkeley.edu or brunner%ibmsupt@uunet.uu.net
uucp: uunet!ibmsupt!brunner		(415) 855-4486