© 2000 Compaq Computer Corporation
Ladebug Debugger Advanced Topics
For that reason there is a wide variation in the level of information provided here under each subtopic.
void loopForDebugger()
{
if (!getenv("loopForDebugger")) return;
static volatile int debuggerPresent = 0;
while (!debuggerPresent);
}
and call it at some convenient point.
When you have the process under debugger control, you will be able to assign
a non-zero value to debuggerPresent, and continue your program.
% setenv loopForDebugger ""
% a.out arg1 arg2 &
% ladebug -pid 1709 a.out
^C
(ladebug) assign debuggerPresent = 1
...
(ladebug) cont
/*% cc -g traceback.c -lexc
**% a.out
*/
struct exception_info;
/* To suppress compilation warnings from sym.h */
#include <demangle.h>
#include <excpt.h>
#include <setjmp.h>
#include <signal.h>
#include <sym.h>
#include <unistd.h>
static void printHeader(void)
{
printf("Diagnostic stack trace ...\n");
}
static void printTrailer(void)
{
printf("end of diagnostic stack trace.\n");
}
#define RETURNADDRREG (26)
#define FAULTING_ADDRESS sc_traparg_a0
extern unsigned long _procedure_string_table;
extern unsigned long _procedure_table_size;
extern unsigned long _procedure_table;
extern unsigned long _ftext; /* Start address of the program text.*/
extern unsigned long _etext; /* First address above the program text.*/
/* Turn a PC into the name of the routine containing that PC.
*/
char* programCounterToName(
unsigned long programCounter);
/* Unwind the stack one level.
*/
void unwindOneLevel(
struct sigcontext* unwindSignalContext,
void * runtimeProcedurePtr);
void printFrame(
void * rpdp,
unsigned long programCounter)
{
char* procedureName;
/* Get the procedure name.
*/
procedureName = programCounterToName(programCounter);
printf("%p %s\n",
(void* ) programCounter, procedureName ? procedureName : "");
}
char* programCounterToName(
unsigned long programCounter)
{
long int procedureTableSize;
char * procedureNameTable;
char * procedureName;
long int currentProcedure;
long int procedure;
pRPDR runTimePDPtr;
int found;
unsigned long int address;
found = 0;
procedureName = 0;
procedureTableSize = (long int)&_procedure_table_size;
procedureNameTable = (char *)&_procedure_string_table;
runTimePDPtr = (pRPDR)&_procedure_table;
/* The table of run time procedure descriptors is ordered by
procedure start address. Search the table (linearly) for the
first procedure with a start address larger than the one for
which we are looking.
*/
for (currentProcedure = 0;
currentProcedure < procedureTableSize;
currentProcedure++) {
/* Because of the way the linker builds the table we need to make
special cases of the first and last entries. The linker uses 0
for the address of the procedure in the first entry, here we
substitute the start address of the text segment. The linker
uses -1 for the address of the procedure in the last entry,
here we substitute the end address of the text segment. For all
other entries the procedure address is obtained from the table.*/
if (currentProcedure == 0) /* first entry */
address = (unsigned long int)&_ftext;
else if (currentProcedure == procedureTableSize - 1) /* last entry */
address = (unsigned long int)&_etext;
else /* other entries */
address = runTimePDPtr[currentProcedure].adr;
if (address > programCounter) {
if (currentProcedure != 0) {
/* the PC is in this image */
found = 1;
procedure = currentProcedure - 1; /* the PC is in preceeding procedure */
break; /* stop searching */
} else {
/* the PC is outside this image (at a lower address) */
break; /* stop searching */ }
}
}
if (found) {
/* the PC is inside this image */
procedureName = &procedureNameTable[runTimePDPtr[procedure].irpss];
} else {
/* the PC is outside this image, probably in a different shared object */
procedureName = 0;
}
return procedureName;
}
void unwindOneLevel(
struct sigcontext *unwindSignalContext,
void * runtimeProcedurePtr)
{
unwind(unwindSignalContext, (pdsc_crd *)runtimeProcedurePtr);
}
/* Print a stack trace.
*/
void printStackWkr(struct sigcontext *signalContextPtr)
{
struct sigcontext unwindSignalContext;
void *runTimeProcedurePtr;
unsigned long int stackpointer = 0;
unsigned long int programCounter = 0;
unsigned long int returnAddress = 0;
unsigned long int faultingAddress = 0;
printHeader();
/* Set the initial context for the unwind.
*/
unwindSignalContext = *signalContextPtr;
/* Pick out the return address and program counter.
*/
returnAddress = unwindSignalContext.sc_regs[RETURNADDRREG];
programCounter = unwindSignalContext.sc_pc;
/* This is the address that caused the fault when we tried to access
it.
*/
faultingAddress = signalContextPtr->FAULTING_ADDRESS;
/* Special cases for bogus program counter values. If the program
counter is zero or the fault occurred when we were trying to
fetch an instruction (because the program counter itself was bad)
then we cannot unwind the stack.
*/
if (programCounter == 0) {
printf("PC is zero - stack trace not available.\n");
} else if (programCounter == faultingAddress) {
printf("bad PC (%p) - stack trace not available.\n",
faultingAddress);
} else {
unsigned int sameSpCount = 0;
/* Loop through all the stack frames.
*/
while ((returnAddress != 0) && (programCounter != 0)) {
/* Get the run time procedure descriptor for this frame.
*/
runTimeProcedurePtr = find_rpd(programCounter);
/* Print a frame.
*/
printFrame(runTimeProcedurePtr, programCounter);
/* Unwind one level.
*/
unwindOneLevel(&unwindSignalContext, runTimeProcedurePtr);
returnAddress = unwindSignalContext.sc_regs[RETURNADDRREG];
programCounter = unwindSignalContext.sc_pc;
if (unwindSignalContext.sc_sp <= stackpointer) {
sameSpCount++;
if (sameSpCount == 10) break;
} else {
sameSpCount = 0;
stackpointer = unwindSignalContext.sc_sp;
}
}
}
printTrailer();
}
/* Discard one stack frame by silently unwinding.
*/
long int discardOneLevel(
long int programCounter,
struct sigcontext *signalContextPtr)
{
void *runTimeProcedurePtr;
runTimeProcedurePtr = find_rpd(programCounter);
unwindOneLevel(signalContextPtr, runTimeProcedurePtr);
return signalContextPtr->sc_pc;
}
void printStack(int levelsToDiscard)
{
long int programCounter;
void *runTimeProcedurePtr;
jmp_buf context;
struct sigcontext *signalContextPtr;
/* Capture the current context.
*/
setjmp(context);
signalContextPtr = (struct sigcontext *)context;
programCounter = signalContextPtr->sc_pc;
/* Discard the frame for this routine.
*/
programCounter = discardOneLevel(programCounter, signalContextPtr);
/* Discard any other frames requested by our caller.
*/
if (levelsToDiscard > 0) {
int levels;
for (levels = 0; levels < levelsToDiscard; levels++) {
programCounter = discardOneLevel(programCounter, signalContextPtr);
}
}
/* Now that we have the right context, print the stack trace.
*/
printStackWkr(signalContextPtr);
}
/* Example of usage follows. */
void innermost()
{
printStack(0);
}
void middle()
{
innermost();
}
int main()
{
middle();
return 0;
}
Decimal digits
DG [0-9]
Octal digits
OC [0-7]
Hexadecimal digits
HX [0-9a-fA-F]
Letters
LT [A-Za-z_$]
Letters from the International Character Set
LTI18N [A-Za-z_$\200-\377]
Characters in words separated by spaces, tabs, semicolons, linefeeds, less-than, greater-than, and quoted strings
WD [^ \t;\n<>'"]
Characters allowed in a file name
FL [^ \t\n\}\;\>\<]
Exponents on the ends of numbers
Exponent [eE][+-]?{DG}+
Whitespace
Whitespace [ \t]+
Strings
stringChar ([^"\\\n]|([\\]({simpleEscape}|{octalEscape}|{hexEscape})))
charChar ([^'\\\n]|([\\]({simpleEscape}|{octalEscape}|{hexEscape})))
simpleEscape ([A-Za-z'"?#\\])
octalEscape ([0-7]{1,3})
hexEscape ([xX][0-9a-fA-F]{1,8})
In all lexical states, unescaped newlines produce the NEWLINE token and change the lexical state to be LKEYWORDS. Note - it may not be possible to use an escaped newline when entering commands from a terminal, because the command line editting process regards the line as finished when it sees the first newline, whether or not it is escaped.
LKEYWORDS, LNORM, LFILE, LLINE, LWORDS, LSIGNAL
[\n] NEWLINE, LKEYWORDS
In most lexical states the spaces, tabs, and escaped newlines are ignored.
LKEYWORDS, LNORM, LFILE, LSIGNAL
[ \t]
\\\n
In the LLINE state the spaces and tabs are part of the line. But escaped newlines are still ignored.
LLINE
\\\n
In the LWORDS state the spaces and tabs are ignored, but escaped newlines are not.
LWORDS
[ \t]
Lexical Token | Representation (some may be language-specific) |
Associated Lexical State Transition | Language Specific? |
ALIAS | alias | Transit to LNORM_with_setTypeLookup | Shared by all |
ALPHADIGITSI18N | [0-9A-Za-z_$\200-\377] | Transit to LNORM | Cobol |
ALPHASDIGITS HYPHENI18N |
[0-9\-A-Za-z_$\200-\377] | Transit to LNORM | Cobol |
AMPERSAND | "&" | Transit to LNORM | C, C++, Fortran, Ada |
AND | AND | Transit to LNORM | Cobol |
ANDAND | "&&" | Transit to LNORM | C, C++, Ada |
ANDassign | "&=" | Transit to LNORM | C, C++ |
ANY | any | Transit to LNORM_reserved_word | Shared by all |
ARROW | "->" | Transit to LNORM | C, C++, Ada |
ARROWstar | "->*" | Transit to LNORM | C++ |
ASSIGN | assign | Transit to LNORM | Shared by all |
ASSIGNOP | "=" | Transit to LNORM | C, C++, Fortran, Ada, Cobol |
AT | at | Transit to LNORM_reserved_word | Shared by all |
ATSIGN | "@" | Transit to LNORM | Shared by all |
ATTACH | attach | Transit to LNORM | Shared by all |
BRACKETS | "[]" | Transit to LNORM | C, C++, Ada |
BYCONTENT | (BY[ \t]+)?"CONTENT" | Transit to LNORM | Cobol |
BYDESCRIPTOR | (BY[ \t]+)?"DESCRIPTOR" | Transit to LNORM | Cobol |
BYREFERENCE | (BY[ \t]+)?"REFERENCE" | Transit to LNORM | Cobol |
BYVALUE | (BY[ \t]+)?"VALUE" | Transit to LNORM | Cobol |
CALL | call | Transit to LNORM | Shared by all |
CATCH | catch | Transit to LSIGNAL | Shared by all |
CATCH_UNALIGN | catch{Whitespace}unaligned | Transit to LNORM | Shared by all |
CHANGED | changed | Transit to LNORM_reserved_word | Shared by all |
CHAR | char | Transit to LNORM | C, C++ |
CLASS | class | Transit to LKEYWORD | C++, C++ Special Case |
CLCL | "::" | Transit to LNORM | C++ |
CLONE | clone | Transit to LNORM | Shared by all |
COLON | ":" | Transit to LNORM | Shared by all |
COMMA | "," | Transit to | Shared by all |
CONDITION | condition | Transit to LNORM | Shared by all |
CONST | const | Transit to LNORM | C, C++ |
CONT | cont | Transit to LNORM | Shared by all |
CONTI | conti | Transit to LNORM | Shared by all |
CONT_THREAD | cont{Whitespace}thread | Transit to LNORM | Shared by all |
DECR | "--" | Transit to LNORM | C, C++, Ada |
DELETE | delete | Transit to LNORM | Shared by all, also used for C++ special case |
DELETE_ALL | delete{Whitespace}"*" delete{Whitespace}all |
Transit to LNORM | Shared by all |
DELSHAREDOBJ | delsharedobj | Transit to LFILE | Shared by all |
DETACH | detach | Transit to LNORM | Shared by all |
DISABLE | disable | Transit to LNORM | Shared by all |
DISABLE_ALL | disable{Whitespace}"*" disable{Whitespace}all |
Transit to LNORM | Shared by all |
DIVassign | "/=" | Transit to LNORM | C, C++, Ada |
DOLLAR | "$" | Transit to LNORM | Shared by all |
DOT | "." | Transit to LNORM | Shared by all |
DOTstar | ".*" | Transit to LNORM | C++ |
DOUBLE | double | Transit to LNORM | C, C++ |
DOWN | down | Transit to LNORM | Shared by all |
DUMP | dump | Transit to LNORM | Shared by all |
EDIT | edit | Transit to LFILE | Shared by all |
ELLIPSIS | "..." | Transit to LNORM | C++ |
ENABLE | enable | Transit to LNORM | Shared by all |
ENABLE_ALL | enable{Whitespace}"*" enable{Whitespace}all |
Transit to LNORM | Shared by all |
ENUM | enum | Transit to LNORM | C, C++ |
EQ | "==" ".EQ." (IS[ \t]+)? ("="|("EQUAL"([ \t]+"TO")?)) |
Transit to LNORM | C, C++, Fortran, Ada, Cobol |
ERassign | "^=" | Transit to LNORM | C, C++ |
EXPON | "**" | Transit to LNORM | Cobol |
EXPORT | export | Transit to LNORM_with_setTypeLookup | Shared by all |
FILECMD | file | Transit to LFILE | Shared by all |
FLOAT | float | Transit to LNORM | C, C++ |
FUNC | func | Transit to LNORM | Shared by all |
GE | ">=" ".GE." (IS[ \t]+)? "NOT"[ \t]+ ("<"|("LESS"([ \t]+"THAN")?)) (IS[ \t]+)? (">="|("GREATER"([ \t]+"THAN")?[ \t] +"OR"[ \t]+"EQUAL"([ \t]+"TO")?)) |
Transit to LNORM | C, C++, Fortran, Ada, Cobol |
GIVING | GIVING | Transit to LNORM | Cobol |
GOTO | goto | Transit to LNORM | Shared by all |
GREATER | ">" ".GT." (IS[ \t]+)? (">"|("GREATER"([ \t]+"THAN")?)) |
Transit to LNORM | Shared by all, also used for Fortran and Cobol special cases |
GUI | gui | Transit to LNORM | Shared by all |
HASH | unknown | Transit to UNKNOWN | Shared by all |
HAT | "^" | Transit to LNORM | C, C++, Ada |
HELP | help | Transit to LLINE | Shared by all |
HISTORY | history | Transit to LNORM | Shared by all |
HPFGET | HPFGET | Transit to LKEYWORD | Fortran |
IF | if | Transit to LNORM_reserved_word | Shared by all |
IGNORE | ignore | Transit to LSIGNAL | Shared by all |
IGNORE_UNALIGN | ignore{Whitespace}unaligned | Transit to LNORM | Shared by all |
IN | in | Transit to LNORM_reserved_word | Shared by all |
INCR | "++" | Transit to LNORM | C, C++, Ada |
INPUT | input | Transit to LFILE | Shared by all |
INT | int | Transit to LNORM | C, C++ |
IN_ALL | in{Whitespace}all{Whitespace} | Transit to LNORM_reserved_word | Shared by all |
IO | io | Transit to LFILE | Shared by all |
KILL | kill | Transit to LNORM | Shared by all |
KPS | kps | Transit to LNORM | Shared by all |
LADEBUG _INTERNAL _DUMPLOADABLE |
ladebug_internal_dumploadable | Transit to LNORM | Shared by all |
LBRACE | "{" | Transit to LKEYWORDS | Shared by all |
LBRACKET | "[" | Transit to LNORM | C, C++, Fortran, Ada |
LE | "<=" ".LE." (IS[ \t]+)?"NOT"[ \t]+ (">"|("GREATER"([ \t]+"THAN")?)) (IS[ \t]+)? ("<="|("LESS"([ \t]+"THAN")?[ \t]+ "OR"[ \t]+"EQUAL"([ \t]+"TO")?)) |
Transit to LNORM | C, C++, Fortran, Ada, Cobol |
LESS | "<" ".LT." (IS[ \t]+)? ("<"|("LESS"([ \t]+"THAN")?)) |
Transit to LNORM | Shared by all, also used for Fortran and Cobol special cases |
LIST | list | Transit to LNORM | Shared by all |
LISTOBJ | listobj | Transit to LNORM | Shared by all |
LOAD | load | Transit to LFILE | Shared by all |
LOGAND | ".AND." | Transit to LNORM | Fortran |
LOGEQV | ".EQV." | Transit to LNORM | Fortran |
LOGNEQV | ".NEQV." | Transit to LNORM | Fortran |
LOGNOT | ".NOT." | Transit to LNORM | Fortran |
LOGOR | ".OR." | Transit to LNORM | Fortran |
LOGXOR | ".XOR." | Transit to LNORM | Fortran |
LONG | long | Transit to LNORM | C, C++ |
LPAREN | "(" | Transit to LNORM | Shared by all |
LS | "<<" | Transit to LNORM | C, C++, Ada |
LSassign | "<<=" | Transit to LNORM | C, C++ |
MINUS | "-" | Transit to LNORM | C, C++, Fortran, Ada, Cobol |
MINUSassign | "-=" | Transit to LNORM | C, C++ |
MOD | "%" MOD |
Transit to LNORM | C, C++, Ada, Cobol |
MODassign | "%=" | Transit to LNORM | C, C++, Ada |
MONITOR_ADD | monitor{Whitespace}add | Transit to LNORM | Shared by all |
MONITOR_REMOVE | monitor{Whitespace}remove | Transit to LNORM | Shared by all |
MULTassign | "*=" | Transit to LNORM | C, C++, Ada |
MUTEX | mutex | Transit to LNORM | Shared by all |
NE | "!=" ".NE." (IS[ \t]+)? "NOT"[ \t]+("="|("EQUAL"([ \t]+"TO")?)) |
Transit to LNORM | C, C++, Fortran, Ada |
NEW | new | Transit to LNORM | C++ |
NEXT | next | Transit to LNORM | Shared by all |
NEXTI | nexti | Transit to LNORM | Shared by all |
NOT | "!" NOT |
Transit to LNORM | C, C++, Ada, Cobol |
OF | OF | Transit to LNORM | Cobol |
OPENSLASH | "(/" | Transit to LNORM | Fortran |
OPERATOR | operator | Transit to LNORM | C++ |
OR | "|" OR |
Transit to LNORM | C, C++, Ada, Cobol |
OROR | "||" | Transit to LNORM | C, C++, Ada |
ORassign | "|=" | Transit to LNORM | C, C++ |
OUTPUT | output | Transit to LFILE | Shared by all |
PARENS | "()" | Transit to LNORM | C++ |
PATCH | patch | Transit to LNORM | Shared by all |
PERCENT | "%" | Transit to LNORM | Fortran |
PLAYBACK | playback | Transit to LKEYWORDS | Shared by all |
PLUS | "+" | Transit to LNORM | C, C++, Fortran, Cobol |
PLUSassign | "+=" | Transit to LNORM | C, C++, Ada |
POLICY | policy | Transit to LNORM_reserved_word | Shared by all |
POP | pop | Transit to LNORM | Shared by all |
Transit to LNORM | Shared by all | ||
PRINTENV | printenv | Transit to LNORM_with_setTypeLookup | Shared by all |
PRINTF | printf | Transit to LNORM | Shared by all |
PRINTREGS | printregs | Transit to LNORM | Shared by all |
PRIORITY | priority | Transit to LNORM_reserved_word | Shared by all |
PROCESS | process | Transit to LNORM | Shared by all |
PROCESS_ALL | process{Whitespace}"*" process{Whitespace}all |
Transit to | Shared by all |
PTHREAD | pthread | Transit to LNORM | Shared by all |
QUESTION | "?" | Transit to LNORM | C, C++, Ada |
QUIT | quit | Transit to LNORM | Shared by all |
RBRACE | "}" | Transit to LKEYWORDS | Shared by all |
RBRACKET | "]" | Transit to LNORM | C, C++, Fortran, Ada |
READ | read | Transit to LNORM_reserved_word | Shared by all |
READSHAREDOBJ | readsharedobj | Transit to LFILE | Shared by all |
RECORD | record | Transit to LKEYWORDS | Shared by all |
REFERENCEOF | REFERENCE([ \t]+"OF")? | Transit to LNORM | Cobol |
RERUN | rerun | Transit to LWORDS | Shared by all |
RETURN | return | Transit to LNORM | Shared by all |
RPAREN | ")" | Transit to LNORM | Shared by all |
RS | ">>" | Transit to LNORM | C, C++, Ada |
RSassign | ">>=" | Transit to LNORM | C, C++ |
RUN | run | Transit to LWORDS | Shared by all |
SAVE | unknown | Transit to UNKNOWN | Shared by all |
SEMICOLON | ";" | Transit to LKEYWORDS_with_setTypeLookup | Shared by all |
SET | set | Transit to LNORM | Shared by all |
SETENV | setenv | Transit to LNORM_with_setTypeLookup | Shared by all |
SET_THREAD | set{Whitespace}thread | Transit to LNORM | Shared by all |
SH | sh | Transit to LNORM | Shared by all |
SHORT | short | Transit to LNORM | C, C++ |
SHOW | show | Transit to LKEYWORDS | Shared by all |
SIGNED | signed | Transit to LNORM | C, C++ |
SIGNNEG | (IS[ \t]+)?"NEGATIVE" (IS[ \t]+)?"NOT"[ \t]+"POSITIVE" |
Transit to LNORM | Cobol |
SIGNNOTZERO | (IS[ \t]+)?"NOT"[ \t]+"ZERO" | Transit to LNORM | Cobol |
SIGNPOS | (IS[ \t]+)?"POSITIVE" (IS[ \t]+)?"NOT"[ \t]+"NEGATIVE" |
Transit to LNORM | Cobol |
SIGNZERO | (IS[ \t]+)?"ZERO" | Transit to LNORM | Cobol |
SIZEOF | sizeof | Transit to LNORM | C, C++, Fortran |
SLASH | "/" | Transit to LNORM | Shared by all |
SLASHCLOSE | "/)" | Transit to LNORM | Fortran |
SLASHSLASH | "//" | Transit to LNORM | Fortran |
SOURCE | source | Transit to LFILE | Shared by all |
STAR | "*" | Transit to LNORM | Shared by all |
STARSTAR | "**" | Transit to LNORM | Fortran |
STATE | state | Transit to LNORM_reserved_word | Shared by all |
STATUS | status | Transit to LNORM | Shared by all |
STEP | step | Transit to LNORM | Shared by all |
STEPI | stepi | Transit to LNORM | Shared by all |
STOP | stop | Transit to LNORM | Shared by all |
STOPI | stopi | Transit to LNORM | Shared by all |
STRUCT | struct | Transit to LNORM | C, C++ |
THREAD | thread | Transit to LNORM_reserved_word | Shared by all |
THREAD_ALL | thread{Whitespace}all thread{Whitespace}"*" |
Transit to LNORM_reserved_word | Shared by all |
TICK | "'" | Transit to LNORM | Shared by all |
TO | to | Transit to LNORM_reserved_word | Shared by all |
TRACE | trace | Transit to LNORM | Shared by all |
TRACEI | tracei | Transit to LNORM | Shared by all |
TWIDDLE | "~" | Transit to LNORM | C, C++, Ada |
UNALIAS | unalias | Transit to LNORM_with_setTypeLookup | Shared by all |
UNION | union | Transit to LNORM | C, C++ |
UNLOAD | unload | Transit to LNORM | Shared by all |
UNSET | unset | Transit to LNORM | Shared by all |
UNSETENV | unsetenv | Transit to LNORM_with_setTypeLookup | Shared by all |
UNSETENV_ALL | unsetenv{Whitespace}"*" | Transit to LNORM | Shared by all |
UNSIGNED | unsigned | Transit to LNORM | C, C++ |
UNUSE | unuse | Transit to LFILE | Shared by all |
UP | up | Transit to LNORM | Shared by all |
USE | use | Transit to LFILE | Shared by all |
USING | USING | Transit to LNORM | Cobol |
VOID | void | Transit to LNORM | C, C++ |
VOLATILE | volatile | Transit to LNORM | C, C++ |
WATCH | watch | Transit to LNORM | Shared by all |
WATCH_MEMORY | watch{Whitespace}memory | Transit to LNORM | Shared by all |
WATCH_VARIABLE | watch{Whitespace}variable | Transit to LNORM | Shared by all |
WHATIS | whatis | Transit to LNORM | Shared by all |
WHEN | when | Transit to LNORM | Shared by all |
WHENI | wheni | Transit to LNORM | Shared by all |
WHERE | where | Transit to LNORM | Shared by all |
WHEREIS | whereis | Transit to LNORM | Shared by all |
WHERE_THREAD | where{Whitespace}thread | Transit to LNORM | Shared by all |
WHERE_THREAD_ALL | where{Whitespace}thread{Whitespace}"*" where{Whitespace}thread{Whitespace}all |
Transit to LNORM | Shared by all |
WHICH | which | Transit to LNORM | Shared by all |
WITH | with | Transit to LNORM_reserved_word | Shared by all |
WITHIN | unknown | Transit to UNKNOWN | Shared by all |
WRITE | write | Transit to LNORM_reserved_word | Shared by all |
Notes:
There are some transitions which are unknown; these are TBD.
LKEYWORD Language Tokens Specific to C
LKEYWORD Language Tokens Specific to C++
<LKEYWORDS>{LTI18N}({LTI18N}|{DG})*
{
SetLexState(lnorm); COPY_KEYWORD;
return (symbolType(yytext, curLexScope, IDENTIFIER, TYPEDEFname));
}
LKEYWORD Language Tokens Specific to Fortran
<LKEYWORDS>class { SetLexState(lnorm); return CLASS; }
<LKEYWORDS>{LTI18N}({LTI18N}|{DG})*
{
SetLexState(lnorm); COPY_KEYWORD;
return (symbolType(yytext, curLexScope, IDENTIFIER, TYPEDEFname));
}
<LKEYWORDS>{LTI18N}({LTI18N}|{DG})*/::
{
COPY_KEYWORD;
return TYPEDEFname;
}
<LKEYWORDS>{LTI18N}({LTI18N}|{DG})*/\<
{
SetLexState(lnorm);
return CheckForTemplate();
}
LWORDS tokens shared by all languages
Transit to LNORM
HPFGET HPFGET
{LT}({LT}|{DG})*
{
COPY_KEYWORD;
return (symbolType(yytext, curLexScope, IDENTIFIER, TYPEDEFname, PROCEDUREname));
}
Transit to LKEYWORDS
[;] { setTypeLookup(TRUE); return SEMICOLON; }
Stay in LWORDS
\> GREATER
\< LESS
">&" GREATERAMPERSAND
"1>" ONEGREATER
"2>" TWOGREATER
[']{charChar}*['] {
return STRINGliteral;
}
["]{stringChar}*["] {
return STRINGliteral;
}
{WD}* {
COPY_KEYWORD_P;
// If the last byte in the token is \ (Backslash), we have to check whether
// it is part of a multi-byte character. If true, we should not treat the
// Backslash as a real escape character.
//
if (yytext[yyleng-1] == '\\' && !(ClosingMB ((unsigned char *)yytext, yyleng)) )
{
/* replace the backslash with the next char */
yytext[yyleng-1] = yyinput();
//
// Usually, flex will update the HighWaterMark before executing
// any action. But, as here we just input an extra character inside
// an action, a manual update of the HighWaterMark is needed
//
cin_UpdateHighWaterMark(1);
yymore();
}
else
{
/* input(); don't flush the whitespace */
BEGIN LWORDS;
return STRINGliteral;
}
}
[lL][']{charChar}+['] {
return WIDECHARACTERconstant;
}
[lL]["]{stringChar}*["] {
return WIDESTRINGliteral;
}
LLINE tokens shared by all languages
Transit to LKEYWORDS
#Cmn-Tokens-Lines# Common Lines
.+ {
COPY_KEYWORD_P;
return STRINGliteral;
}
LFILE tokens shared by all languages
Transit to LKEYWORDS
[;] SEMICOLON
[\}] RBRACE
Stay in LFILE
{FL}+ {
COPY_KEYWORD;
return(FILENAME);
}
Transit to LWORDS
\> GREATER
\< LESS
">&" GREATERAMPERSAND
LSIGNAL tokens shared by all languages
Transit to LKEYWORDS
[;] SEMICOLON
[\}] RBRACE
Stay in LSIGNAL
{DG}+ lexUnsignedLong(yytext, 10, INTEGERconstant, BOGUS, &yylval)
{LT}({LT}|{DG})* IDENTIFIER
LNORM tokens shared by all languages
Transit to LKEYWORDS
";" setTypeLookup(TRUE); SEMICOLON
"{" LBRACE
// why doesn't the following setTypeLookup(TRUE)?
//
with{Whitespace}event lexReservedWordyy(WITHEVENT)
Stay in LNORM
// why doesn't this SetLexState(lkeywords)
"}" RBRACE
Stay in LNORM
":" COLON
"`" TICK
"@" ATSIGN
"$" DOLLAR
"." DOT
"/" SLASH
"," COMMA
"*" STAR
"<" LESS
">" GREATER
["]{stringChar}*["] STRINGliteral
[']{charChar}+['] {
if (strlen(...) == 1) { /* zero length is disallowed by the grammer */
return CHARACTERconstant;
} else {
return STRINGliteral;
}
}
[lL][']{charChar}+['] {
return WIDECHARACTERconstant;
}
[lL]["]{stringChar}*["] {
return WIDESTRINGliteral;
}
"(" iParenLevel++; LPAREN
")" iParenLevel--; RPAREN
in lexReservedWordyy(IN)
in{Whitespace}all{Whitespace} lexReservedWordyy(IN_ALL)
at lexReservedWordyy(AT)
if lexReservedWordyy(IF)
thread lexReservedWordyy(THREAD)
thread{Whitespace}all lexReservedWordyy(THREAD_ALL)
thread{Whitespace}"*" lexReservedWordyy(THREAD_ALL)
to lexReservedWordyy(TO)
policy lexReservedWordyy(POLICY)
priority lexReservedWordyy(PRIORITY)
state lexReservedWordyy(STATE)
with lexReservedWordyy(WITH)
any lexReservedWordyy(ANY)
changed lexReservedWordyy(CHANGED)
read lexReservedWordyy(READ)
write lexReservedWordyy(WRITE)
#Cmn-Tokens-Reserved# Reserved Words
int lexReservedWordyy(int iReservedToken)
{
if (iParenLevel == 0)
return iReservedToken;
else
{
COPY_KEYWORD;
return symbolType(yytext, curLexScope,
IDENTIFIER, TYPEDEFname,
PROCEDUREname);
}
}
// Function: symbolType
//
// Purpose: This function takes the name of a symbol, and the values
// that correspond to its possible meta-types (i.e. identifier,
// typename, etc.), or -1 if the symbol cannot hold a certain type.
// The function looks up the name in the current language context,
// and based on the language, returns the type of the symbol.
// The default type is "identifier"
//
int symbolType (
const String s,
Scope* const currentLexicalScope,
const int identifier,
const int typedefname,
const int procname)
// Look up the symbol, using the current language.
// This function sets whether the symbolType function looks up types
// in the symbol table, or whether simply returns IDENTIFIER, which is
// much quicker. This gives a toggle switch to the symbol-table-
// feedback-to-the-lexer-hack that's been an integral part of grammars
// for typed languages since the stone age. It also allows a smooth
// migration from using this system to using semantic analysis
// instead.
//
void setTypeLookup(Boolean lookupTypes);
// If yytext[yyleng-1] == '\\' then
// check whether it closes a legal multi-byte character.
//
static inline Boolean ClosingMB (unsigned char *token, int leng)
#Cmn-Concepts-Filename# Common Concepts - Filename
NEED TO DISTINQUISH BETWEEN DIRECTORIES, SOURCE FILES, LOADABLE FILES
filename
: FILENAME
| string
/* The following productions allow a user to use the unload command,
* until it gets fixed in a better way (i.e. redesigned).
*/
| IDENTIFIER
| IDENTIFIER DOT IDENTIFIER
Stay in LNORM
"->" ARROW
"++" INCR
"--" DECR
"<<" LS
">>" RS
"<=" LE
">=" GE
"==" EQ
"!=" NE
"&&" ANDAND
"||" OROR
"*=" MULTassign
"/=" DIVassign
"%=" MODassign
"+=" PLUSassign
"-=" MINUSassign
"<<=" LSassign
">>=" RSassign
"&=" ANDassign
"^=" ERassign
"|=" ORassign
"+" PLUS
"-" MINUS
"%" MOD
"^" HAT
"&" AMPERSAND
"|" OR
"~" TWIDDLE
"!" NOT
"[]" BRACKETS
"=" ASSIGNOP
"[" LBRACKET
"]" RBRACKET
"?" QUESTION
char CHAR
double DOUBLE
float FLOAT
int INT
long LONG
short SHORT
signed SIGNED
unsigned UNSIGNED
void VOID
const CONST
volatile VOLATILE
sizeof SIZEOF
enum ENUM
struct STRUCT
union UNION
INTEGER constant
"0"{OC}+
"0"[xX]{HX}+
{DG}+
FLOATING constant (lexDouble)
{DG}*"."{DG}*
{DG}*"."{DG}*{Whitespace}?{Exponent}
{DG}+ {Whitespace}?{Exponent}
IDENTIFIER or TYPEDEFname
{LTI18N}({LTI18N}|{DG})*
"->" ARROW
"++" INCR
"--" DECR
"<<" LS
">>" RS
"<=" LE
">=" GE
"==" EQ
"!=" NE
"&&" ANDAND
"||" OROR
"..." ELLIPSIS
"::" CLCL
".*" DOTstar
"->*" ARROWstar
"*=" MULTassign
"/=" DIVassign
"%=" MODassign
"+=" PLUSassign
"-=" MINUSassign
"<<=" LSassign
">>=" RSassign
"&=" ANDassign
"^=" ERassign
"|=" ORassign
"+" PLUS
"-" MINUS
"%" MOD
"^" HAT
"&" AMPERSAND
"|" OR
"~" TWIDDLE
"!" NOT
"[]" BRACKETS
"()" PARENS
"=" ASSIGNOP
"[" LBRACKET
"]" RBRACKET
"?" QUESTION
operator OPERATOR
char CHAR
double DOUBLE
float FLOAT
int INT
long LONG
short SHORT
signed SIGNED
unsigned UNSIGNED
void VOID
new NEW
delete DELETE
const CONST
volatile VOLATILE
sizeof SIZEOF
class CLASS
enum ENUM
struct STRUCT
union UNION
INTEGERconstant
"0"{OC}+
"0"[xX]{HX}+
{DG}+
FLOATINGconstant (double)
{DG}*"."{DG}*
{DG}*"."{DG}* { Whitespace}?{Exponent}
{DG}+{Whitespace}?{Exponent}
IDENTIFIER, TYPEDEFname
{LTI18N}({LTI18N}|{DG})*
TYPEDEFname
{LTI18N}({LTI18N}|{DG})*/::
IDENTIFIER, TYPEDEFname
{LTI18N}({LTI18N}|{DG})*/\<
{
return CheckForTemplate();
}
int CheckForTemplate()
{
ASSERT(yytext[strlen(yytext)-1] != '<');
// Also if the string before the name is "operator" then don't check
// for this as a template.
//
const char* strOperator = "operator";
const int iLength = strlen(strOperator);
if (strlen(yytext) == iLength &&
strcmp(yytext, strOperator) == 0)
return OPERATOR;
// Possible template - check for it as a type name.
char b[1024];
int opencnt = 0;
// Make a copy of the string.
strcpy(b, yytext);
if (templateLexerDebug)
cout << "yytext = `" << yytext << "'." << endl;
for (char* c = b+strlen(yytext); (c-b) < 1024; )
{
// Read in the next character and NULL-terminate the string.
*c = yyinput();
*(c+1)='\0';
if (templateLexerDebug)
{
cout << "ENTRY:" << endl;
cout << " Just read `" << (char )*c << "'." << endl;
cout << " Buffer `" << b << "'." << endl;
cout << " Paren. Level = " << opencnt << endl;
}
if (*c == '<')
{
opencnt++;
}
if (*c == '\n')
{
for (; c >= (b+strlen(yytext)); c--)
unput((int)*c); // unput < also
COPY_KEYWORD;
return IDENTIFIER;
}
if ((*c == '>')&&(*(c - 1) == '>'))
{
// we've encountered '>>' to close two templates. We need
// to insert a space between them for name lookup. (e.g.
// Foo> => Foo > )
*(c+2) = '\0';
*(c+1) = *c;
*c = ' ';
c++;
}
if ((*c == '>')&&(--opencnt == 0))
{
c++;
*c = '\0';
if (symbolType(b, curLexScope, IDENTIFIER, TYPEDEFname) == TYPEDEFname)
{
yylval.sval = duplicateString(b);
return TYPEDEFname;
}
else
{
for (c--; c >= (b+strlen(yytext)); c--)
unput((int)*c);
COPY_KEYWORD;
return IDENTIFIER;
}
}
else if (!((*c == ' ') || (*c == '\t')))
{
// Omit spaces and tabs because demangler does this also
c++;
}
if (templateLexerDebug)
{
cout << "EXIT:" << endl;
cout << " Just read `" << (char )*c << "'." << endl;
cout << " Buffer `" << b << "'." << endl;
cout << " Paren. Level = " << opencnt << endl;
}
}
COPY_KEYWORD;
return IDENTIFIER;
}
"+" PLUS
"-" MINUS
"**" STARSTAR
".LT." LESS
".LE." LE
".EQ." EQ
".NE." NE
".GE." GE
".GT." GREATER
"<=" LE
"==" EQ
"/=" NE
">=" GE
".NOT." LOGNOT
".AND." LOGAND
".OR." LOGOR
".EQV." LOGEQV
".NEQV." LOGNEQV
".XOR." LOGXOR
"%" PERCENT
"=" ASSIGNOP
"//" SLASHSLASH
"(/" OPENSLASH
"/)" SLASHCLOSE
"[" LBRACKET
"]" RBRACKET
"&" AMPERSAND
sizeof SIZEOF
Integer Constants
".TRUE."
".FALSE."
"0"{OC}+
"0X"{HX}+
{DG}+
Floating Point Constants
{DG}*"."{DG}*
{DG}*"."{DG}*{Whitespace}?{Exponent}
{DG}+{Whitespace}?{Exponent}
IDENTIFIER, TYPEDEFname
{LT}({LT}|{DG})*
"->" ARROW
"++" INCR
"--" DECR
"<<" LS
">>" RS
"<=" LE
">=" GE
"==" EQ
"!=" NE
"&&" ANDAND
"||" OROR
"*=" MULTassign
"/=" DIVassign
"%=" MODassign
"+=" PLUSassign
"-=" MINUSassign
"<<=" LSassign
">>=" RSassign
"&=" ANDassign
"^=" ERassign
"|=" ORassign
"+" PLUS
"-" MINUS
"%" MOD
"^" HAT
"&" AMPERSAND
"|" OR
"~" TWIDDLE
"!" NOT
"[]" BRACKETS
"=" ASSIGNOP
"[" LBRACKET
"]" RBRACKET
"?" QUESTION
INTEGERconstant
"0"{OC}+
"0X"{HX}+
{DG}+
FLOATINGconstant
{DG}*"."{DG}+
{DG}*"."{DG}*{Whitespace}?{Exponent}
{DG}+{Whitespace}?{Exponent}
IDENTIFIER, TYPEDEFname
{LT}({LT}|{DG})*
ALPHASDIGITSI18N [0-9A-Za-z_$\200-\377]
ALPHASDIGITSHYPHENI18N [0-9\-A-Za-z_$\200-\377]
IntLit [-+]?{DG}+
DecLit [-+]?{DG}*\.{DG}+
FloatLit [-+]?(({DG}+\.{DG}*)|({DG}*\.{DG}*))("E"[+-]?{DG}+)
CHexLit "0X"{HX}+
CobolHexLit "X"((\"({HX}{HX})+["\n])|('({HX}{HX})+['\n]))
CobolWord {ALPHASDIGITSI18N}|({ALPHASDIGITSI18N}{ALPHASDIGITSI18N})|({ALPHASDIGITSI18N}+{ALPHASDIGITSHYPHENI18N}+{ALPHASDIGITSI18N}+)
"=" ASSIGNOP
" + " PLUS
" - " MINUS
"**" EXPON
"&" AMPERSAND
AND AND
MOD MOD
NOT NOT
OR OR
REFERENCE([ \t]+"OF")? REFERENCEOF
OF OF
GIVING GIVING
USING USING
(BY[ \t]+)?"REFERENCE" BYREFERENCE
(BY[ \t]+)?"VALUE" BYVALUE
(BY[ \t]+)?"CONTENT" BYCONTENT
(BY[ \t]+)?"DESCRIPTOR" BYDESCRIPTOR
(IS[ \t]+)?"POSITIVE" SIGNPOS
(IS[ \t]+)?"NEGATIVE" SIGNNEG
(IS[ \t]+)?"ZERO" SIGNZERO
(IS[ \t]+)?"NOT"[ \t]+"POSITIVE" SIGNNEG
(IS[ \t]+)?"NOT"[ \t]+"NEGATIVE" SIGNPOS
(IS[ \t]+)?"NOT"[ \t]+"ZERO" SIGNNOTZERO
(IS[ \t]+)?("="|("EQUAL"([ \t]+"TO")?)) EQ
(IS[ \t]+)?("<"|("LESS"([ \t]+"THAN")?)) LESS
(IS[ \t]+)?(">"|("GREATER"([ \t]+"THAN")?)) GREATER
(IS[ \t]+)?"NOT"[ \t]+("="|("EQUAL"([ \t]+"TO")?)) NE
(IS[ \t]+)?"NOT"[ \t]+("<"|("LESS"([ \t]+"THAN")?)) GE
(IS[ \t]+)?"NOT"[ \t]+(">"|("GREATER"([ \t]+"THAN")?)) LE
(IS[ \t]+)?("<="|("LESS" ([ \t]+"THAN")?[ \t]+"OR"[ \t]+"EQUAL"([ \t]+"TO")?)) LE
(IS[ \t]+)?(">="|("GREATER"([ \t]+"THAN")?[ \t]+"OR"[ \t]+"EQUAL"([ \t]+"TO")?)) GE
DECIMALconstant
{DecLit}
INTEGERconstant
{IntLit} DECIMAL
{CHexLit} HEXADECIMAL
{CobolHexLit} HEXADECIMAL
FLOATINGconstant
{FloatLit}
IDENTIFIER
{CobolWord}
TBD Reference target for Examine Command...
TBD Reference target for Set Command...
#Cmn-AND-expression# Common Expressions - AND-expression
AND-expression
: AND-expression for C
| AND-expression for C++
| AND-expression for Ada
#Cmn-abstract-declarator# Common Expressions - abstract-declarator
abstract-declarator
: abstract-declarator for C
| abstract-declarator for C++
| abstract-declarator for Ada
#Cmn-actual-arg# Common Expressions - actual-arg
actual-arg
: actual-arg for Fortran
#Cmn-actual-arg-spec# Common Expressions - actual-arg-spec
actual-arg-spec
: actual-arg-spec for Fortran
#Cmn-actual-arg-spec-list# Common Expressions - actual-arg-spec-list
actual-arg-spec-list
: actual-arg-spec-list for Fortran
#Cmn-add-operand# Common Expressions - add-operand
add-operand
: add-operand for Fortran
#Cmn-add-operand-dec# Common Expressions - add-operand-dec
add-operand-dec
: add-operand-dec for Fortran
#Cmn-add-operand-f90# Common Expressions - add-operand-f90
add-operand-f90
: add-operand-f90 for Fortran
#Cmn-additive-expression# Common Expressions - additive-expression
additive-expression
: additive-expression for C
| additive-expression for C++
| additive-expression for Ada
#Cmn-address# Common Expressions - address
address
: address for C
| address for C++
| address for Fortran
| address for Ada
| address for Cobol
#Cmn-address-exp# Common Expressions - address-exp
address-exp
: address-exp for C
| address-exp for C++
| address-exp for Fortran
| address-exp for Ada
| address-exp for Cobol
#Cmn-address-language# Common Expressions - address-language
address-language
: address-language for Cobol
#Cmn-aggregate-key# Common Expressions - aggregate-key
aggregate-key
: aggregate-key for C++
#Cmn-aggregate-name# Common Expressions - aggregate-name
aggregate-name
: aggregate-name for C++
#Cmn-allocation-expression# Common Expressions - allocation-expression
allocation-expression
: allocation-expression for C++
#Cmn-and-operand# Common Expressions - and-operand
and-operand
: and-operand for Fortran
#Cmn-any-identifier# Common Expressions - any-identifier
any-identifier
: any-identifier for Fortran
#Cmn-Expr-Arglist# Common Expressions - Argument list
argument-expression-list
: assignment-expression
| assignment-expression COMMA argument-expression-list
arg-expression-list-opt
: argument-expression-list
| /* Nothing at all */
#Cmn-array-abstract-declarator# Common Expressions - array-abstract-declarator
array-abstract-declarator
: array-abstract-declarator for C
| array-abstract-declarator for C++
| array-abstract-declarator for Ada
#Cmn-array-elt-or-sect# Common Expressions - array-elt-or-sect
array-elt-or-sect
: array-elt-or-sect for Fortran
#Cmn-assignment-expression# Common Expressions - assignment-expression
assignment-expression
: assignment-expression for C
| assignment-expression for C++
| assignment-expression for Fortran
| assignment-expression for Ada
| assignment-expression for Cobol
#Cmn-basic-type-name# Common Expressions - basic-type-name
basic-type-name
: basic-type-name for C
| basic-type-name for C++
#Cmn-basic-type-specifier# Common Expressions - basic-type-specifier
basic-type-specifier
: basic-type-specifier for C
| basic-type-specifier for C++
#Cmn-call-expression# Common Expressions - call-expression
call-expression
: call-expression for C
| call-expression for C++
| call-expression for Fortran
| call-expression for Ada
| call-expression for Cobol
#Cmn-call-stmt# Common Expressions - call-stmt
call-stmt
: call-stmt for Fortran
#Cmn-cast-expression# Common Expressions - cast-expression
cast-expression
: cast-expression for C
| cast-expression for C++
| cast-expression for Ada
#Cmn-cobol-expression# Common Expressions - cobol-expression
cobol-expression
: cobol-expression for Cobol
#Cmn-cobol-expression-list# Common Expressions - cobol-expression-list
cobol-expression-list
: cobol-expression-list for Cobol
#Cmn-cobol-identifier# Common Expressions - cobol-identifier
cobol-identifier
: cobol-identifier for Cobol
#Cmn-combined-condition# Common Expressions - combined-condition
combined-condition
: combined-condition for Cobol
#Cmn-comma-opt-ellipsis# Common Expressions - comma-opt-ellipsis
comma-opt-ellipsis
: comma-opt-ellipsis for C++
#Cmn-complex-constant# Common Expressions - complex-constant
complex-constant
: complex-constant for Fortran
#Cmn-condition-expression# Common Expressions - condition-expression
condition-expression
: condition-expression for Cobol
#Cmn-conditional-expression# Common Expressions - conditional-expression
conditional-expression
: conditional-expression for C
| conditional-expression for C++
| conditional-expression for Ada
#Cmn-constant# Common Expressions - constant
constant
: constant for C
| constant for Fortran
#Cmn-constant-expression# Common Expressions - constant-expression
constant-expression
: constant-expression for C
| constant-expression for C++
| constant-expression for Fortran
| constant-expression for Ada
| constant-expression for Cobol
#Cmn-deallocation-expression# Common Expressions - deallocation-expression
deallocation-expression
: deallocation-expression for C++
#Cmn-defined-binary-op# Common Expressions - defined-binary-op
defined-binary-op
: defined-binary-op for Fortran
#Cmn-defined-unary-op# Common Expressions - defined-unary-op
defined-unary-op
: defined-unary-op for Fortran
#Cmn-disabled-array-elt-or-sect# Common Expressions - disabled-array-elt-or-sect
disabled-array-elt-or-sect
: disabled-array-elt-or-sect for Fortran
#Cmn-elaborated-type-name# Common Expressions - elaborated-type-name
elaborated-type-name
: elaborated-type-name for C
| elaborated-type-name for C++
#Cmn-embedded-key-word# Common Expressions - embedded-key-word
embedded-key-word
: ANY
| CHANGED
| READ
| WRITE
#Cmn-enum-name# Common Expressions - enum-name
enum-name
: enum-name for C++
#Cmn-enum-specifier# Common Expressions - enum-specifier
enum-specifier
: enum-specifier for C
#Cmn-equality-expression# Common Expressions - equality-expression
equality-expression
: equality-expression for C
| equality-expression for C++
| equality-expression for Ada
#Cmn-equiv-operand# Common Expressions - equiv-operand
equiv-operand
: equiv-operand for Fortran
#Cmn-exclusive-OR-expression# Common Expressions - exclusive-OR-expression
exclusive-OR-expression
: exclusive-OR-expression for C
| exclusive-OR-expression for C++
| exclusive-OR-expression for Ada
#Cmn-expr# Common Expressions - expr
expr
: expr for Fortran
#Cmn-expression# Common Expressions - expression
expression
: expression for C
| expression for C++
| expression for Fortran
| expression for Ada
| expression for Cobol
#Cmn-Expr-expression-opt# Common Expressions - Optional expressions
expression-opt
: expression
| /* Nothing at all */
#Cmn-Expr-filename-opt# Common Expressions - Optional filenames
filename-opt
: filename
| /* Nothing at all */
#Cmn-filename-tick# Common Expressions - filename-tick
filename-tick
: string-tick
#Cmn-function-reference# Common Expressions - function-reference
function-reference
: function-reference for Fortran
#Cmn-hf-array-abomination# Common Expressions - hf-array-abomination
hf-array-abomination
: hf-array-abomination for Fortran
#Cmn-identifier-or-key-word# Common Expressions - identifier-or-key-word
identifier-or-key-word
: IDENTIFIER
| embedded-key-word
#Cmn-identifier-or-typedef-name# Common Expressions - identifier-or-typedef-name
identifier-or-typedef-name
: identifier-or-typedef-name for C
| identifier-or-typedef-name for C++
| identifier-or-typedef-name for Fortran
| identifier-or-typedef-name for Ada
| identifier-or-typedef-name for Cobol
#Cmn-inclusive-OR-expression# Common Expressions - inclusive-OR-expression
inclusive-OR-expression
: inclusive-OR-expression for C
| inclusive-OR-expression for C++
| inclusive-OR-expression for Ada
#Cmn-int-expr# Common Expressions - int-expr
int-expr
: int-expr for Fortran
#Cmn-known-substring# Common Expressions - known-substring
known-substring
: known-substring for Fortran
#Cmn-level-1-expr# Common Expressions - level-1-expr
level-1-expr
: level-1-expr for Fortran
#Cmn-level-2-expr# Common Expressions - level-2-expr
level-2-expr
: level-2-expr for Fortran
#Cmn-level-3-expr# Common Expressions - level-3-expr
level-3-expr
: level-3-expr for Fortran
#Cmn-level-4-expr# Common Expressions - level-4-expr
level-4-expr
: level-4-expr for Fortran
#Cmn-level-5-expr# Common Expressions - level-5-expr
level-5-expr
: level-5-expr for Fortran
#Cmn-line-address# Common Expressions - line-address
line-address
: ATSIGN string COLON line-number
| ATSIGN line-number
#Cmn-line-number# Common Expressions - line-number
line-number
: INTEGERconstant /* line number int */
| DOLLAR /* last line */
#Cmn-loc# Common Expressions - loc
loc
: loc for C
| loc for C++
| loc for Fortran
| loc for Ada
| loc for Cobol
#Cmn-loc-address# Common Expressions - loc-address
loc-address
: loc-address for C
| loc-address for C++
| loc-address for Fortran
| loc-address for Ada
| loc-address for Cobol
#Cmn-logical-AND-expression# Common Expressions - logical-AND-expression
logical-AND-expression
: logical-AND-expression for C
| logical-AND-expression for C++
| logical-AND-expression for Ada
#Cmn-logical-OR-expression# Common Expressions - logical-OR-expression
logical-OR-expression
: logical-OR-expression for C
| logical-OR-expression for C++
| logical-OR-expression for Ada
#Cmn-lvalue-expression# Common Expressions - lvalue-expression
lvalue-expression
: lvalue-expression for Cobol
#Cmn-mult-operand-dec# Common Expressions - mult-operand-dec
mult-operand-dec
: mult-operand-dec for Fortran
#Cmn-mult-operand-f90# Common Expressions - mult-operand-f90
mult-operand-f90
: mult-operand-f90 for Fortran
#Cmn-multiplicative-expression# Common Expressions - multiplicative-expression
multiplicative-expression
: multiplicative-expression for C
| multiplicative-expression for C++
| multiplicative-expression for Ada
#Cmn-named-function# Common Expressions - named-function
named-function
: named-function for Fortran
#Cmn-named-procedure# Common Expressions - named-procedure
named-procedure
: named-procedure for Fortran
#Cmn-named-subroutine# Common Expressions - named-subroutine
named-subroutine
: named-subroutine for Fortran
#Cmn-named-variable# Common Expressions - named-variable
named-variable
: named-variable for Fortran
#Cmn-namespace-rescoped-follower# Common Expressions - namespace-rescoped-follower
namespace-rescoped-follower
: namespace-rescoped-follower for C++
#Cmn-namespace-rescoped-identifier# Common Expressions - namespace-rescoped-identifier
namespace-rescoped-identifier
: namespace-rescoped-identifier for C++
#Cmn-negated-simple-condition# Common Expressions - negated-simple-condition
negated-simple-condition
: negated-simple-condition for Cobol
#Cmn-operator-function-name# Common Expressions - operator-function-name
operator-function-name
: operator-function-name for C++
#Cmn-operator-new# Common Expressions - operator-new
operator-new
: operator-new for C++
#Cmn-operator-new-initializer# Common Expressions - operator-new-initializer
operator-new-initializer
: operator-new-initializer for C++
#Cmn-or-operand# Common Expressions - or-operand
or-operand
: or-operand for Fortran
#Cmn-parameter-type-list# Common Expressions - parameter-type-list
parameter-type-list
: parameter-type-list for C++
#Cmn-point-member-expression# Common Expressions - point-member-expression
point-member-expression
: point-member-expression for C++
#Cmn-pointer-operator-type# Common Expressions - pointer-operator-type
pointer-operator-type
: pointer-operator-type for C++
#Cmn-postfix-abstract-declarator# Common Expressions - postfix-abstract-declarator
postfix-abstract-declarator
: postfix-abstract-declarator for C
| postfix-abstract-declarator for C++
| postfix-abstract-declarator for Ada
#Cmn-postfix-expression# Common Expressions - postfix-expression
postfix-expression
: postfix-expression for C
| postfix-expression for C++
| postfix-expression for Ada
#Cmn-postfixing-abstract-declarator# Common Expressions - postfixing-abstract-declarator
postfixing-abstract-declarator
: postfixing-abstract-declarator for C
| postfixing-abstract-declarator for C++
| postfixing-abstract-declarator for Ada
#Cmn-primary# Common Expressions - primary
primary
: primary for Fortran
#Cmn-primary-expression# Common Expressions - primary-expression
primary-expression
: primary-expression for C
| primary-expression for C++
| primary-expression for Ada
#Cmn-qual-symbol-opt# Common Expressions - qual-symbol-opt
qual-symbol-opt
: expression /* Base (global) name */
| qual-symbol-opt TICK expression /* Qualified name */
#Cmn-qual-symbol-with-null-opt# Common Expressions - qual-symbol-with-null-opt
qual-symbol-with-null-opt
: qual-symbol-opt
| /* Nothing at all */
#Cmn-qual-typedef-opt# Common Expressions - qual-typedef-opt
qual-typedef-opt
: qual-typedef-opt for C
| qual-typedef-opt for C++
| qual-typedef-opt for Fortran
| qual-typedef-opt for Ada
| qual-typedef-opt for Cobol
#Cmn-real-or-imag-part# Common Expressions - real-or-imag-part
real-or-imag-part
: real-or-imag-part for Fortran
#Cmn-relational-expression# Common Expressions - relational-expression
relational-expression
: relational-expression for C
| relational-expression for C++
| relational-expression for Ada
#Cmn-rescoped-expression# Common Expressions - rescoped-expression
rescoped-expression
: filename-tick qual-symbol-opt
| TICK qual-symbol-opt
#Cmn-rescoped-identifier# Common Expressions - rescoped-identifier
rescoped-identifier
: rescoped-identifier for C++
#Cmn-rescoped-typedef# Common Expressions - rescoped-typedef
rescoped-typedef
: filename-tick qual-typedef-opt
| TICK qual-typedef-opt
#Cmn-scalar-int-expr# Common Expressions - scalar-int-expr
scalar-int-expr
: scalar-int-expr for Fortran
#Cmn-section-subscript# Common Expressions - section-subscript
section-subscript
: section-subscript for Fortran
#Cmn-section-subscript-list# Common Expressions - section-subscript-list
section-subscript-list
: section-subscript-list for Fortran
#Cmn-shift-expression# Common Expressions - shift-expression
shift-expression
: shift-expression for C
| shift-expression for C++
| shift-expression for Ada
#Cmn-simple-condition# Common Expressions - simple-condition
simple-condition
: simple-condition for Cobol
#Cmn-stride# Common Expressions - stride
stride
: stride for Fortran
#Cmn-string# Common Expressions - string
string
: STRINGliteral
#Cmn-string-literal-list# Common Expressions - string-literal-list
string-literal-list
: string-literal-list for C
| string-literal-list for C++
| string-literal-list for Ada
#Cmn-string-tick# Common Expressions - string-tick
string-tick
: string TICK
#Cmn-struct-or-union# Common Expressions - struct-or-union
struct-or-union
: struct-or-union for C
#Cmn-struct-or-union-specifier# Common Expressions - struct-or-union-specifier
struct-or-union-specifier
: struct-or-union-specifier for C
#Cmn-struct-union-enum-type-specifier# Common Expressions - struct-union-enum-type-specifier
struct-union-enum-type-specifier
: struct-union-enum-type-specifier for C
| struct-union-enum-type-specifier for C++
#Cmn-structure# Common Expressions - structure
structure
: structure for Fortran
#Cmn-structure-component# Common Expressions - structure-component
structure-component
: structure-component for Fortran
#Cmn-subobject# Common Expressions - subobject
subobject
: subobject for Fortran
#Cmn-subscript# Common Expressions - subscript
subscript
: subscript for Fortran
#Cmn-subscript-triplet# Common Expressions - subscript-triplet
subscript-triplet
: subscript-triplet for Fortran
#Cmn-substring-range# Common Expressions - substring-range
substring-range
: substring-range for Fortran
#Cmn-type-name# Common Expressions - type-name
type-name
: type-name for C
| type-name for C++
| type-name for Fortran
| type-name for Ada
#Cmn-type-name-list# Common Expressions - type-name-list
type-name-list
: type-name-list for C++
#Cmn-type-qualifier# Common Expressions - type-qualifier
type-qualifier
: type-qualifier for C
| type-qualifier for C++
#Cmn-type-qualifier-list# Common Expressions - type-qualifier-list
type-qualifier-list
: type-qualifier-list for C
| type-qualifier-list for C++
#Cmn-type-qualifier-list-opt# Common Expressions - type-qualifier-list-opt
type-qualifier-list-opt
: type-qualifier-list-opt for C++
#Cmn-type-specifier# Common Expressions - type-specifier
type-specifier
: type-specifier for C
| type-specifier for C++
| type-specifier for Ada
#Cmn-typedef-type-specifier# Common Expressions - typedef-type-specifier
typedef-type-specifier
: typedef-type-specifier for C
| typedef-type-specifier for C++
| typedef-type-specifier for Ada
#Cmn-unary-abstract-declarator# Common Expressions - unary-abstract-declarator
unary-abstract-declarator
: unary-abstract-declarator for C
| unary-abstract-declarator for C++
| unary-abstract-declarator for Ada
#Cmn-unary-expr-dec# Common Expressions - unary-expr-dec
unary-expr-dec
: unary-expr-dec for Fortran
#Cmn-unary-expression# Common Expressions - unary-expression
unary-expression
: unary-expression for C
| unary-expression for C++
| unary-expression for Fortran
| unary-expression for Ada
| unary-expression for Cobol
#Cmn-variable# Common Expressions - variable
variable
: variable for Fortran
#Cmn-variable-name# Common Expressions - variable-name
variable-name
: variable-name for Fortran
#Cmn-whatis-expressions# Common Expressions - whatis-expressions
whatis-expressions
: whatis-expressions for C
| whatis-expressions for C++
| whatis-expressions for Fortran
| whatis-expressions for Ada
| whatis-expressions for Cobol
Miscellaneous
address
: AMPERSAND postfix-expression
| line-address
| postfix-expression
address-exp
: address
| address-exp PLUS address
| address-exp MINUS address
| address-exp STAR address
call-expression
: expression
identifier-or-typedef-name
: identifier-or-key-word
| TYPEDEFname
loc
: expression
| rescoped-expression
loc-address
: AMPERSAND postfix-expression
| AMPERSAND identifier-or-typedef-name PLUS INTEGERconstant
| AMPERSAND identifier-or-typedef-name MINUS INTEGERconstant
qual-typedef-opt
: TYPEDEFname
| qual-typedef-opt TICK TYPEDEFname
whatis-expressions
: expression
| rescoped-expression
| type-name
| rescoped-typedef
Expressions
expression
: assignment-expression
constant-expression
: conditional-expression
assignment-expression
: conditional-expression
| unary-expression ASSIGNOP assignment-expression
| unary-expression MULTassign assignment-expression
| unary-expression DIVassign assignment-expression
| unary-expression MODassign assignment-expression
| unary-expression PLUSassign assignment-expression
| unary-expression MINUSassign assignment-expression
| unary-expression LSassign assignment-expression
| unary-expression RSassign assignment-expression
| unary-expression ANDassign assignment-expression
| unary-expression ERassign assignment-expression
| unary-expression ORassign assignment-expression
conditional-expression
: logical-OR-expression
| logical-OR-expression QUESTION expression COLON conditional-expression
logical-OR-expression
: logical-AND-expression
| logical-OR-expression OROR logical-AND-expression
logical-AND-expression
: inclusive-OR-expression
| logical-AND-expression ANDAND inclusive-OR-expression
inclusive-OR-expression
: exclusive-OR-expression
| inclusive-OR-expression OR exclusive-OR-expression
exclusive-OR-expression
: AND-expression
| exclusive-OR-expression HAT AND-expression
AND-expression
: equality-expression
| AND-expression AMPERSAND equality-expression
equality-expression
: relational-expression
| equality-expression EQ relational-expression
| equality-expression NE relational-expression
relational-expression
: shift-expression
| relational-expression LESS shift-expression
| relational-expression GREATER shift-expression
| relational-expression LE shift-expression
| relational-expression GE shift-expression
shift-expression
: additive-expression
| shift-expression LS additive-expression
| shift-expression RS additive-expression
additive-expression
: multiplicative-expression
| additive-expression PLUS multiplicative-expression
| additive-expression MINUS multiplicative-expression
multiplicative-expression
: cast-expression
| multiplicative-expression STAR cast-expression
| multiplicative-expression SLASH cast-expression
| multiplicative-expression MOD cast-expression
cast-expression
: unary-expression
| LPAREN type-name RPAREN cast-expression
unary-expression
: postfix-expression
| INCR unary-expression
| DECR unary-expression
| AMPERSAND cast-expression
| STAR cast-expression
| PLUS cast-expression
| MINUS cast-expression
| TWIDDLE cast-expression
| NOT cast-expression
| SIZEOF unary-expression
| SIZEOF LPAREN type-name RPAREN
| line-address
postfix-expression
: primary-expression
| postfix-expression LBRACKET expression RBRACKET
| postfix-expression LPAREN arg-expression-list-opt RPAREN
| postfix-expression DOT identifier-or-typedef-name
| postfix-expression ARROW identifier-or-typedef-name
| postfix-expression INCR
| postfix-expression DECR
primary-expression
: identifier-or-key-word
| constant
| string-literal-list
| LPAREN expression RPAREN
string-literal-list
: string
| string-literal-list string
constant
: FLOATINGconstant
| INTEGERconstant
| CHARACTERconstant
| WIDECHARACTERconstant
| WIDESTRINGliteral
// Note: ENUMERATIONconstant are treated as identifiers
Types
type-specifier
: basic-type-specifier
| struct-union-enum-type-specifier
| typedef-type-specifier
basic-type-specifier
: basic-type-name
| type-qualifier-list basic-type-name
| basic-type-specifier type-qualifier
| basic-type-specifier basic-type-name
type-qualifier-list
: type-qualifier
| type-qualifier-list type-qualifier
type-qualifier
: CONST
| VOLATILE
basic-type-name
: VOID
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
struct-union-enum-type-specifier
: elaborated-type-name
| type-qualifier-list elaborated-type-name
| struct-union-enum-type-specifier type-qualifier
typedef-type-specifier
: TYPEDEFname
| type-qualifier-list TYPEDEFname
| typedef-type-specifier type-qualifier
elaborated-type-name
: struct-or-union-specifier
| enum-specifier
struct-or-union-specifier
: struct-or-union identifier-or-typedef-name
struct-or-union
: STRUCT
| UNION
enum-specifier
: ENUM identifier-or-typedef-name
type-name
: type-specifier
| type-specifier abstract-declarator
| type-qualifier-list // Implicit "int"
| type-qualifier-list abstract-declarator // Implicit "int"
abstract-declarator
: unary-abstract-declarator
| postfix-abstract-declarator
| postfixing-abstract-declarator
postfixing-abstract-declarator
: array-abstract-declarator
| LPAREN RPAREN
array-abstract-declarator
: BRACKETS
| LBRACKET constant-expression RBRACKET
| array-abstract-declarator LBRACKET constant-expression RBRACKET
unary-abstract-declarator
: STAR
| STAR type-qualifier-list
| STAR abstract-declarator
| STAR type-qualifier-list abstract-declarator
postfix-abstract-declarator
: LPAREN unary-abstract-declarator RPAREN
| LPAREN postfix-abstract-declarator RPAREN
| LPAREN postfixing-abstract-declarator RPAREN
| LPAREN unary-abstract-declarator RPAREN postfixing-abstract-declarator
#C++Expr#
/* Limitations in this grammar include:
*
* In new, casts, and sizeof, we do not allow functions to be specified with
* arguments. That is, the following is not supported:
*
* int (*) (double)
*
* but the following is supported:
*
* int (*) ()
*
* Similarly, all other ambiguities between expressions and declarations are
* resolved in favor of expressions. This is because we are a debugger and we
* do not support declarations at all.
address
: AMPERSAND postfix-expression /* Address of */
| line-address
| postfix-expression
address-exp
: address
| address-exp PLUS address
| address-exp MINUS address
| address-exp STAR address
call-expression
: expression
/* We are not including ENUMERATIONconstant here because we
* are treating it like a variable with a type of "enumeration
* constant".
*/
constant
: FLOATINGconstant
| INTEGERconstant
| CHARACTERconstant
| WIDECHARACTERconstant
| WIDESTRINGliteral
identifier-or-typedef-name
: identifier-or-key-word
| TYPEDEFname
loc
: TWIDDLE TYPEDEFname
| TYPEDEFname
| CLCL TYPEDEFname
| expression
| rescoped-expression
loc-address
: AMPERSAND postfix-expression
| LPAREN type-name RPAREN AMPERSAND postfix-expression PLUS INTEGERconstant
| AMPERSAND postfix-expression PLUS INTEGERconstant
| LPAREN type-name RPAREN AMPERSAND postfix-expression MINUS INTEGERconstant
| AMPERSAND postfix-expression MINUS INTEGERconstant
qual-typedef-opt
: TYPEDEFname /* Base (global) name */
| TWIDDLE TYPEDEFname /* Base (global) name */
| qual-typedef-opt TICK TYPEDEFname /* Qualified name */
| qual-typedef-opt TICK TWIDDLE TYPEDEFname /* Qualified name */
string-literal-list
: string
| string-literal-list string
whatis-expressions
: expression
| rescoped-expression
| rescoped-typedef
| type-name
| TWIDDLE TYPEDEFname
rescoped-identifier
: operator-function-name /* C++, not ANSI C */
| namespace-rescoped-identifier
namespace-rescoped-identifier
: TYPEDEFname CLCL namespace-rescoped-follower
namespace-rescoped-follower
: TWIDDLE TYPEDEFname /* C++, not ANSI C */
| namespace-rescoped-identifier /* C++, not ANSI C */
| operator-function-name /* C++, not ANSI C */
| identifier-or-typedef-name /* C++, not ANSI C */
primary-expression
: THIS /* C++, not ANSI C */
| CLCL identifier-or-key-word
| CLCL operator-function-name
| rescoped-identifier
| identifier-or-key-word /* Or typedefname? */
| constant
| string-literal-list
| LPAREN expression RPAREN
operator-function-name
: OPERATOR PLUS
| OPERATOR MINUS
| OPERATOR STAR
| OPERATOR SLASH
| OPERATOR MOD
| OPERATOR HAT
| OPERATOR AMPERSAND
| OPERATOR OR
| OPERATOR TWIDDLE
| OPERATOR NOT
| OPERATOR LESS
| OPERATOR GREATER
| OPERATOR LS
| OPERATOR RS
| OPERATOR ANDAND
| OPERATOR OROR
| OPERATOR ARROW
| OPERATOR INCR
| OPERATOR DECR
| OPERATOR LE
| OPERATOR GE
| OPERATOR EQ
| OPERATOR NE
| OPERATOR ASSIGNOP
| OPERATOR MULTassign
| OPERATOR DIVassign
| OPERATOR MODassign
| OPERATOR PLUSassign
| OPERATOR MINUSassign
| OPERATOR LSassign
| OPERATOR RSassign
| OPERATOR ANDassign
| OPERATOR ERassign
| OPERATOR ORassign
| OPERATOR PARENS
| OPERATOR BRACKETS
| OPERATOR NEW
| OPERATOR DELETE
| OPERATOR COMMA
| OPERATOR basic-type-name
| OPERATOR TYPEDEFname
| OPERATOR LPAREN type-name RPAREN
| OPERATOR type-qualifier
type-qualifier-list-opt
: /* Nothing at all */
| type-qualifier-list
postfix-expression
: primary-expression
| postfix-expression LBRACKET expression RBRACKET
| postfix-expression PARENS
| postfix-expression LPAREN argument-expression-list RPAREN
| postfix-expression LPAREN type-name-list RPAREN
| postfix-expression DOT identifier-or-typedef-name
| postfix-expression DOT TWIDDLE TYPEDEFname
| postfix-expression DOT rescoped-identifier
| postfix-expression ARROW identifier-or-typedef-name
| postfix-expression ARROW rescoped-identifier
| postfix-expression ARROW TWIDDLE TYPEDEFname
| postfix-expression INCR
| postfix-expression DECR
| TYPEDEFname LPAREN argument-expression-list RPAREN
| TWIDDLE TYPEDEFname LPAREN argument-expression-list RPAREN
| TYPEDEFname LPAREN type-name-list RPAREN
| TWIDDLE TYPEDEFname LPAREN type-name-list RPAREN
| basic-type-name LPAREN assignment-expression RPAREN
/* For disambiguating overloaded function names */
type-name-list
: type-name
| type-name COMMA type-name-list
| type-name comma-opt-ellipsis
| ELLIPSIS /* C++, not ANSI C */
comma-opt-ellipsis
: ELLIPSIS /* C++ */
| ',' ELLIPSIS
unary-expression
: postfix-expression
| INCR unary-expression
| DECR unary-expression
| line-address
| AMPERSAND cast-expression
| STAR cast-expression
| MINUS cast-expression
| PLUS cast-expression
| TWIDDLE LPAREN cast-expression RPAREN
| NOT cast-expression
| SIZEOF unary-expression
| SIZEOF LPAREN type-name RPAREN
| allocation-expression
allocation-expression
: operator-new LPAREN type-name RPAREN operator-new-initializer
| operator-new LPAREN argument-expression-list RPAREN LPAREN type-name
operator-new
: NEW
| CLCL NEW
operator-new-initializer
: /* Nothing at all */
| PARENS
| LPAREN argument-expression-list RPAREN
cast-expression
: unary-expression
| LPAREN type-name RPAREN cast-expression
deallocation-expression
: cast-expression
| DELETE deallocation-expression
| CLCL DELETE deallocation-expression
| DELETE BRACKETS deallocation-expression
| CLCL DELETE BRACKETS deallocation-expression
point-member-expression
: deallocation-expression
| point-member-expression DOTstar deallocation-expression
| point-member-expression ARROWstar deallocation-expression
multiplicative-expression
: point-member-expression
| multiplicative-expression STAR point-member-expression
| multiplicative-expression SLASH point-member-expression
| multiplicative-expression MOD point-member-expression
additive-expression
: multiplicative-expression
| additive-expression PLUS multiplicative-expression
| additive-expression MINUS multiplicative-expression
shift-expression
: additive-expression
| shift-expression LS additive-expression
| shift-expression RS additive-expression
relational-expression
: shift-expression
| relational-expression LESS shift-expression
| relational-expression GREATER shift-expression
| relational-expression LE shift-expression
| relational-expression GE shift-expression
equality-expression
: relational-expression
| equality-expression EQ relational-expression
| equality-expression NE relational-expression
AND-expression
: equality-expression
| AND-expression AMPERSAND equality-expression
exclusive-OR-expression
: AND-expression
| exclusive-OR-expression HAT AND-expression
inclusive-OR-expression
: exclusive-OR-expression
| inclusive-OR-expression OR exclusive-OR-expression
logical-AND-expression
: inclusive-OR-expression
| logical-AND-expression ANDAND inclusive-OR-expression
logical-OR-expression
: logical-AND-expression
| logical-OR-expression OROR logical-AND-expression
conditional-expression
: logical-OR-expression
| logical-OR-expression QUESTION expression COLON conditional-expression
assignment-expression
: conditional-expression
| unary-expression ASSIGNOP assignment-expression
| unary-expression MULTassign assignment-expression
| unary-expression DIVassign assignment-expression
| unary-expression MODassign assignment-expression
| unary-expression PLUSassign assignment-expression
| unary-expression MINUSassign assignment-expression
| unary-expression LSassign assignment-expression
| unary-expression RSassign assignment-expression
| unary-expression ANDassign assignment-expression
| unary-expression ERassign assignment-expression
| unary-expression ORassign assignment-expression
expression
: assignment-expression
constant-expression
: conditional-expression
type-specifier
: basic-type-specifier
| struct-union-enum-type-specifier
| typedef-type-specifier
type-qualifier-list
: type-qualifier
| type-qualifier-list type-qualifier
type-qualifier
: CONST
| VOLATILE
basic-type-specifier
: basic-type-name basic-type-name
| basic-type-name type-qualifier
| type-qualifier-list basic-type-name
| basic-type-specifier type-qualifier
| basic-type-specifier basic-type-name
struct-union-enum-type-specifier
: elaborated-type-name
| type-qualifier-list elaborated-type-name
| struct-union-enum-type-specifier type-qualifier
typedef-type-specifier
: TYPEDEFname type-qualifier
| type-qualifier-list TYPEDEFname
| typedef-type-specifier type-qualifier
basic-type-name
: VOID
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
elaborated-type-name
: aggregate-name
| enum-name
aggregate-name
: aggregate-key identifier-or-typedef-name
aggregate-key
: STRUCT
| UNION
| CLASS
enum-name
: ENUM identifier-or-typedef-name
parameter-type-list
: PARENS type-qualifier-list-opt
type-name
: type-specifier
| basic-type-name
| CLCL TYPEDEFname
| TYPEDEFname
| type-qualifier-list
| type-specifier abstract-declarator
| basic-type-name abstract-declarator
| CLCL TYPEDEFname abstract-declarator
| TYPEDEFname abstract-declarator
| type-qualifier-list abstract-declarator
abstract-declarator
: unary-abstract-declarator
| postfix-abstract-declarator
| postfixing-abstract-declarator
postfixing-abstract-declarator
: array-abstract-declarator
| parameter-type-list
array-abstract-declarator
: BRACKETS
| LBRACKET constant-expression RBRACKET
| array-abstract-declarator LBRACKET constant-expression RBRACKET
unary-abstract-declarator
: STAR
| AMPERSAND
| pointer-operator-type
| STAR abstract-declarator
| AMPERSAND abstract-declarator
| pointer-operator-type abstract-declarator
postfix-abstract-declarator
: LPAREN unary-abstract-declarator RPAREN
| LPAREN postfix-abstract-declarator RPAREN
| LPAREN postfixing-abstract-declarator RPAREN
| LPAREN unary-abstract-declarator RPAREN postfixing-abstract-declarator
pointer-operator-type
: TYPEDEFname CLCL STAR type-qualifier-list-opt
| STAR type-qualifier-list
| AMPERSAND type-qualifier-list
Miscellaneous
address
: line-address
| primary /* includes AMPERSAND variable */
address-exp
: address
| address-exp PLUS address
| address-exp MINUS address
| address-exp STAR address
loc
: expression
| rescoped-expression
loc-address
: AMPERSAND variable
| AMPERSAND identifier-or-typedef-name PLUS INTEGERconstant
| AMPERSAND identifier-or-typedef-name MINUS INTEGERconstant
qual-typedef-opt
: TYPEDEFname /* Base (global) name */
| qual-typedef-opt TICK TYPEDEFname /* Qualified name */
whatis-expressions
: expression
| rescoped-expression
| rescoped-typedef
| type-name
Expressions
expression
: expr
| named-procedure
assignment-expression
: expr
constant-expression
: constant
unary-expression
: variable
expr
: level-5-expr
| expr defined-binary-op level-5-expr
level-5-expr
: equiv-operand
| level-5-expr LOGEQV equiv-operand
| level-5-expr LOGNEQV equiv-operand
| level-5-expr LOGXOR equiv-operand
equiv-operand
: or-operand
| equiv-operand LOGOR or-operand
or-operand
: and-operand
| or-operand LOGAND and-operand
and-operand
: level-4-expr
| LOGNOT and-operand
level-4-expr
: level-3-expr
| level-3-expr LESS level-3-expr
| level-3-expr GREATER level-3-expr
| level-3-expr LE level-3-expr
| level-3-expr GE level-3-expr
| level-3-expr EQ level-3-expr
| level-3-expr NE level-3-expr
level-3-expr
: level-2-expr
| level-3-expr SLASHSLASH level-2-expr
level-2-expr
: add-operand
| level-2-expr PLUS add-operand
| level-2-expr MINUS add-operand
add-operand
: add-operand-f90
| add-operand-dec
| unary-expr-dec
add-operand-f90
: mult-operand-f90
| add-operand-f90 STAR mult-operand-f90
| add-operand-f90 SLASH mult-operand-f90
mult-operand-f90
: level-1-expr
| level-1-expr STARSTAR mult-operand-f90
add-operand-dec
: mult-operand-dec
| add-operand-f90 STAR mult-operand-dec
| add-operand-f90 SLASH mult-operand-dec
| add-operand-f90 STAR unary-expr-dec
| add-operand-f90 SLASH unary-expr-dec
mult-operand-dec
: level-1-expr STARSTAR mult-operand-dec
| level-1-expr STARSTAR unary-expr-dec
unary-expr-dec
: PLUS add-operand
| MINUS add-operand
level-1-expr
: primary
| defined-unary-op primary
defined-unary-op
: DOT_LETTERS_DOT
primary
: constant
| variable
| function-reference
| LPAREN expr RPAREN
| AMPERSAND variable /* Address of */
constant
: FLOATINGconstant
| INTEGERconstant
| complex-constant
| string
complex-constant
: LPAREN real-or-imag-part COMMA real-or-imag-part RPAREN
real-or-imag-part
: FLOATINGconstant
| PLUS FLOATINGconstant
| MINUS FLOATINGconstant
| INTEGERconstant
| PLUS INTEGERconstant
| MINUS INTEGERconstant
defined-binary-op
: DOT_LETTERS_DOT
int-expr
: expr
scalar-int-expr
: int-expr
variable
: named-variable
| subobject
named-variable
: variable-name
subobject
: array-elt-or-sect
| structure-component
| known-substring
known-substring
: disabled-array-elt-or-sect LPAREN substring-range RPAREN
| hf-array-abomination
substring-range
: scalar-int-expr COLON scalar-int-expr
| scalar-int-expr COLON
| COLON scalar-int-expr
| COLON
hf-array-abomination
: named-variable
LPAREN section-subscript-list RPAREN
LPAREN section-subscript RPAREN
| structure PERCENT any-identifier
LPAREN section-subscript-list RPAREN
LPAREN section-subscript RPAREN
| structure DOT any-identifier
LPAREN section-subscript-list RPAREN
LPAREN section-subscript RPAREN
disabled-array-elt-or-sect
: DISABLER array-elt-or-sect
array-elt-or-sect
: named-variable LPAREN section-subscript-list RPAREN
| structure PERCENT any-identifier LPAREN section-subscript-list RPAREN
| structure DOT any-identifier LPAREN section-subscript-list RPAREN
section-subscript-list
: section-subscript
| section-subscript COMMA section-subscript-list
subscript
: scalar-int-expr
section-subscript
: subscript
| subscript-triplet
subscript-triplet
: subscript COLON subscript COLON stride
| subscript COLON COLON stride
| COLON subscript COLON stride
| COLON COLON stride
| subscript COLON subscript
| subscript COLON
| COLON subscript
| COLON
stride
: scalar-int-expr
structure-component
: structure PERCENT any-identifier
| structure DOT any-identifier
structure
: named-variable
| structure-component
| array-elt-or-sect
function-reference
: SIZEOF LPAREN expr RPAREN
| named-function LPAREN RPAREN
| named-function LPAREN actual-arg-spec-list RPAREN
named-procedure
: PROCEDUREname
named-function
: PROCEDUREname
named-subroutine
: PROCEDUREname
actual-arg-spec-list
: actual-arg-spec
| actual-arg-spec COMMA actual-arg-spec-list
actual-arg-spec
: actual-arg
actual-arg
: expr
any-identifier
: variable-name
| PROCEDUREname
variable-name
: identifier-or-key-word
identifier-or-typedef-name
: identifier-or-key-word
| TYPEDEFname
| PROCEDUREname
call-expression
: call-stmt
call-stmt
: named-subroutine
| named-subroutine LPAREN RPAREN
| named-subroutine LPAREN actual-arg-spec-list RPAREN
Types
type-name
: TYPEDEFname
#Ada#
address
: INTEGERconstant /* Numeric address */
| line-address
| AMPERSAND identifier-or-typedef-name /* Address of */
| LPAREN expression RPAREN
address-exp
: address
| address-exp PLUS address
| address-exp MINUS address
| address-exp STAR address
call-expression
: expression
/* CONSTANTS: We are not including ENUMERATIONconstant here because we
* are treating it like a variable with a type of "enumeration constant".
*/
constant
: FLOATINGconstant
| INTEGERconstant
| CHARACTERconstant
loc
: expression
| rescoped-expression
loc-address
: AMPERSAND identifier-or-typedef-name
| AMPERSAND identifier-or-typedef-name PLUS INTEGERconstant
| AMPERSAND identifier-or-typedef-name MINUS INTEGERconstant
qual-typedef-opt
: TYPEDEFname /* Base (global) name */
| qual-symbol-opt TICK TYPEDEFname /* Qualified name */
whatis-expressions
: expression
| rescoped-expression
| rescoped-typedef
| type-name
primary-expression
: identifier-or-key-word /* Cannot use typedef name as variable */
| constant /* Const */
| string-literal-list
| LPAREN expression RPAREN
postfix-expression
: primary-expression
| postfix-expression LBRACKET expression RBRACKET
| postfix-expression LPAREN arg-expression-list-opt RPAREN
| postfix-expression DOT identifier-or-typedef-name
| postfix-expression ARROW identifier-or-typedef-name
| postfix-expression INCR
| postfix-expression DECR
string-literal-list
: string
| string-literal-list string
unary-expression
: postfix-expression
| INCR unary-expression
| DECR unary-expression
| AMPERSAND cast-expression
| line-address
| STAR cast-expression
| PLUS cast-expression
| MINUS cast-expression
| TWIDDLE cast-expression
| NOT cast-expression
cast-expression
: unary-expression
| LPAREN type-name RPAREN cast-expression
multiplicative-expression
: cast-expression
| multiplicative-expression STAR cast-expression
| multiplicative-expression SLASH cast-expression
| multiplicative-expression MOD cast-expression
additive-expression
: multiplicative-expression
| additive-expression PLUS multiplicative-expression
| additive-expression MINUS multiplicative-expression
shift-expression
: additive-expression
| shift-expression LS additive-expression
| shift-expression RS additive-expression
relational-expression
: shift-expression
| relational-expression LESS shift-expression
| relational-expression GREATER shift-expression
| relational-expression LE shift-expression
| relational-expression GE shift-expression
equality-expression
: relational-expression
| equality-expression EQ relational-expression
| equality-expression NE relational-expression
AND-expression
: equality-expression
| AND-expression AMPERSAND equality-expression
exclusive-OR-expression
: AND-expression
| exclusive-OR-expression HAT AND-expression
inclusive-OR-expression
: exclusive-OR-expression
| inclusive-OR-expression OR exclusive-OR-expression
logical-AND-expression
: inclusive-OR-expression
| logical-AND-expression ANDAND inclusive-OR-expression
logical-OR-expression
: logical-AND-expression
| logical-OR-expression OROR logical-AND-expression
conditional-expression
: logical-OR-expression
| logical-OR-expression QUESTION expression COLON conditional-expression
assignment-expression
: conditional-expression
| unary-expression ASSIGNOP assignment-expression
| unary-expression MULTassign assignment-expression
| unary-expression DIVassign assignment-expression
| unary-expression MODassign assignment-expression
| unary-expression PLUSassign assignment-expression
| unary-expression MINUSassign assignment-expression
| unary-expression LSassign assignment-expression
| unary-expression RSassign assignment-expression
| unary-expression ANDassign assignment-expression
| unary-expression ERassign assignment-expression
| unary-expression ORassign assignment-expression
expression
: assignment-expression
constant-expression
: conditional-expression
type-specifier
: typedef-type-specifier
typedef-type-specifier
: TYPEDEFname
identifier-or-typedef-name
: identifier-or-key-word
| TYPEDEFname
type-name
: type-specifier
| type-specifier abstract-declarator
abstract-declarator
: unary-abstract-declarator
| postfix-abstract-declarator
| postfixing-abstract-declarator
postfixing-abstract-declarator
: array-abstract-declarator
| LPAREN RPAREN
array-abstract-declarator
: BRACKETS
| LBRACKET constant-expression RBRACKET
| array-abstract-declarator LBRACKET constant-expression RBRACKET
unary-abstract-declarator
: STAR
| STAR abstract-declarator
postfix-abstract-declarator
: LPAREN unary-abstract-declarator RPAREN
| LPAREN postfix-abstract-declarator RPAREN
| LPAREN postfixing-abstract-declarator RPAREN
| LPAREN unary-abstract-declarator RPAREN postfixing-abstract-declarator
#Cobol#
address
: INTEGERconstant /* Absolute */
| line-address
| address-language /* Language-specific address format */
| LPAREN cobol-expression RPAREN
address-exp
: address
| address-exp PLUS address
| address-exp MINUS address
| address-exp STAR address
address-language
/* Address of, C way (for convenience in COBOL only) */
: AMPERSAND cobol-identifier
/* Address of, COBOL way (COBOL extension by Digital) */
| REFERENCEOF cobol-identifier
assignment-expression
: expression
call-expression
: identifier-or-key-word
| identifier-or-key-word USING cobol-expression-list
cobol-expression
: cobol-identifier
| constant
| string
| cobol-expression PLUS cobol-expression
| cobol-expression MINUS cobol-expression
| cobol-expression STAR cobol-expression
| cobol-expression SLASH cobol-expression
| cobol-expression EXPON cobol-expression
| '-' cobol-expression %prec UMINUS
| '+' cobol-expression %prec UPLUS
| LPAREN cobol-expression RPAREN
cobol-expression-list
: cobol-expression
| cobol-expression COMMA cobol-expression-list
cobol-identifier
: qualification
| subscript
| refmod
condition-expression
: combined-condition
| negated-simple-condition
combined-condition
: negated-simple-condition AND negated-simple-condition
| negated-simple-condition OR negated-simple-condition
| LPAREN combined-condition RPAREN
negated-simple-condition
: simple-condition
| NOT simple-condition
| LPAREN NOT simple-condition RPAREN
simple-condition
: cobol-expression EQ cobol-expression
| cobol-expression ASSIGNOP cobol-expression
| cobol-expression NE cobol-expression
| cobol-expression LESS cobol-expression
| cobol-expression GREATER cobol-expression
| cobol-expression LE cobol-expression
| cobol-expression GE cobol-expression
| cobol-expression SIGNPOS
| cobol-expression SIGNNEG
| cobol-expression SIGNZERO
| cobol-expression SIGNNOTZERO
| LPAREN simple-condition RPAREN
constant
: FLOATINGconstant
| INTEGERconstant
| DECIMALconstant
| CHARACTERconstant
constant-expression
: cobol-expression
expression
: constant-expression
| condition-expression
| address-language
identifier-or-typedef-name
: identifier-or-key-word
loc
: cobol-identifier
| rescoped-expression
loc-address
: AMPERSAND identifier-or-typedef-name
| AMPERSAND identifier-or-typedef-name PLUS INTEGERconstant
| AMPERSAND identifier-or-typedef-name MINUS INTEGERconstant
lvalue-expression
: cobol-identifier
qual-typedef-opt
: TYPEDEFname
| qual-typedef-opt TICK TYPEDEFname
qualification
: identifier-or-key-word OF qualification
| identifier-or-key-word
refmod
: qualification LPAREN cobol-expression COLON RPAREN
| qualification LPAREN cobol-expression COLON cobol-expression RPAREN
| subscript LPAREN cobol-expression COLON RPAREN
| subscript LPAREN cobol-expression COLON cobol-expression RPAREN
subscript
: qualification LPAREN cobol-expression-list RPAREN
unary-expression
: lvalue-expression
whatis-expressions
: expression
| rescoped-expression
| rescoped-typedef
% ladebug executable_file core_fileor
(ladebug) load executable_file core_fileThe executable file is the binary that was running at the time the core file was generated.
The stack trace lists the functions in your program that were active when the dump occurred. By examining the values of a few variables along with the stack trace, you may be able to pinpoint the process state and the cause of the core dump. Core files cannot be executed; therefore the rerun, step, cont, etc. commands will not work until you create a process using the run command.
In addition, if the program is multithreaded, you can examine the native thread information with the show thread and thread commands. You can examine the stack trace for a particular thread or all threads with the where thread command.
The following example uses a null pointer reference in the factorial function. This reference causes the process to abort and dump the core when it is executed. The dump command prints the value of the x variable as a null, and the print *x command reveals that you cannot dereference a null pointer.
% cat testProgram.c #include <stdio.h> int factorial(int i) main() { int i,f; for (i=1 ; i<3 ; i++) { f = factorial(i); printf("%d! = %d\en",i,f); } } int factorial(int i) int i; { int *x; x = 0; printf("%d",*x); if (i<=1) return (1); else return (i * factorial(i-1) ); } % cc -o testProgram -g testProgram.c % testProgram Memory fault - core dumped. % ladebug testProgram core Welcome to the Ladebug Debugger Version n ------------------ object file name: testProgram core file name: core Reading symbolic information ...done Core file produced from executable testProgram Thread terminated at PC 0x120000dc4 by signal SEGV (ladebug) where >0 0x120000dc4 in factorial(i=1) testProgram.c:13 #1 0x120000d44 in main() testProgram.c:4 (ladebug) dump >0 0x120000dc4 in factorial(i=1) testProgram.c:13 printf("%d",*x); (ladebug) print *x Cannot dereference 0x0 Error: no value for *x (ladebug)
You need to collect a variety of files from the original system. These include the executable, the core file, shared libraries used by the executable, and /usr/shlib/libpthreaddebug.so if DECthreads is involved.
Do the following steps (1 through 4) on the original system:
% ladebug a.out core (ladebug) listobj (ladebug) quit
% tar cfvh mybug.tar
On the current system, the executable and core file are generally put in the current working directory, the shared objects are put in an "application" subdirectory, and libpthreaddebug.so is put in a "debugger" subdirectory.
% mkdir mybug
% cd mybug
% mv <wherever>/mybug.tar .
% mkdir applibs dbglibs
% tar xfvs mybug.tar
% mv usr/shlib/* applibs
If the tar xfvs output in Step 9 moved shared objects into other directories, move them into applibs as well.
% ln -s ../applibs/libpthreaddebug.so dbglibs/libpthreaddebug.so
% env LADEBUG_COREFILE_LIBRARY_PATH=applibs \ LD_LIBRARY_PATH=dbglibs \ ladebug a.out core
(ladebug) listobj
(ladebug)
Create the core file:
% a.out -segv Segmentation fault (core dumped)Determine the shared objects using the debugger on the original system:
% ladebug a.out core Welcome to the Ladebug Debugger Version 4.0-n ------------------ object file name: a.out core file name: core Reading symbolic information ...done Core file produced from executable a.out Thread 0x5 terminated at PC 0x3ff8058b448 by signal SEGV (ladebug) listobj section Start Addr End Addr ------------------------------------------------------------------------------ a.out .text 0x120000000 0x120003fff .data 0x140000000 0x140001fff /usr/shlib/libpthread.so .text 0x3ff80550000 0x3ff8058bfff .data 0x3ffc0180000 0x3ffc018ffff .bss 0x3ffc0190000 0x3ffc01901af /usr/shlib/libmach.so .text 0x3ff80530000 0x3ff8053ffff .data 0x3ffc0170000 0x3ffc0173fff /usr/shlib/libexc.so .text 0x3ff807b0000 0x3ff807b5fff .data 0x3ffc0210000 0x3ffc0211fff /usr/shlib/libc.so .text 0x3ff80080000 0x3ff8019ffff .data 0x3ffc0080000 0x3ffc0093fff .bss 0x3ffc0094000 0x3ffc00a040f (ladebug) quitCut, paste, and edit the result into a list of filenames. Note that libpthread.so is included, so add /usr/shlib/libpthreaddebug.so to the list.
Create a tar file:
% tar cfv mybug.tar a.out core \ /usr/shlib/libpthread.so /usr/shlib/libmach.so \ /usr/shlib/libexc.so /usr/shlib/libc.so \ /usr/shlib/libpthreaddebug.so a a.out 128 Blocks a core 2128 Blocks a /usr/shlib/libpthread.so 928 Blocks a /usr/shlib/libmach.so 208 Blocks a /usr/shlib/libexc.so 96 Blocks a /usr/shlib/libc.so symbolic link to ../../shlib/libc.so a /usr/shlib/libpthreaddebug.so 592 BlocksNote that libc.so is a symbolic link. Therefore, you should use the tar h option to force tar to follow symbolic links as if they were normal files or directories.
% tar hcfv mybug.tar a.out core \ /usr/shlib/libpthread.so /usr/shlib/libmach.so \ /usr/shlib/libexc.so /usr/shlib/libc.so \ /usr/shlib/libpthreaddebug.so a a.out 128 Blocks a core 2128 Blocks a /usr/shlib/libpthread.so 928 Blocks a /usr/shlib/libmach.so 208 Blocks a /usr/shlib/libexc.so 96 Blocks a /usr/shlib/libc.so 3193 Blocks a /usr/shlib/libpthreaddebug.so 592 Blocks
Now you have a "package" that can be transported.
On the current system, create a directory for debugging, move to that directory, and get the package.
% mkdir mybug % cd mybug % mv <wherever>/mybug.tar .
Create the necessary subdirectories and unpackage the tar file using the s option:
% mkdir applibs dbglibs % tar xfvs mybug.tar blocksize = 256 x a.out, 65536 bytes, 128 tape blocks x core, 1089536 bytes, 2128 tape blocks x usr/shlib/libpthread.so, 475136 bytes, 928 tape blocks x usr/shlib/libmach.so, 106496 bytes, 208 tape blocks x usr/shlib/libexc.so, 49152 bytes, 96 tape blocks x usr/shlib/libc.so, 1634400 bytes, 3193 tape blocks x usr/shlib/libpthreaddebug.so, 303104 bytes, 592 tape blocks
Move the original shared objects into applibs, and make libpthreaddebug.so exist in the dbglibs directory, e.g. by linking it to the file in the applibs directory.
% mv usr/shlib/* applibs % ln -s ../applibs/libpthreaddebug.so dbglibs/libpthreaddebug.soIn this example, all shared objects were in usr/shlib/ so no other moving is needed.
Observe the file system:
% ls -lR total 4904 -rwxr-xr-x 1 user1 ladebug 65536 Sep 17 11:20 a.out* drwxrwxr-x 2 user1 ladebug 8192 Sep 17 11:36 applibs/ -rw------- 1 user1 ladebug 1089536 Sep 17 11:21 core drwxrwxr-x 2 user1 ladebug 8192 Sep 17 11:24 dbglibs/ -rw-rw-r-- 1 user1 ladebug 3737600 Sep 17 11:23 mybug.tar drwxrwxr-x 3 user1 ladebug 8192 Sep 17 11:36 usr/ ./applibs: total 2632 -rw-r--r-- 1 user1 ladebug 1634400 Dec 7 1998 libc.so -rw-r--r-- 1 user1 ladebug 49152 Jun 26 1998 libexc.so -rw-r--r-- 1 user1 ladebug 106496 Dec 29 1997 libmach.so -rw-r--r-- 1 user1 ladebug 475136 Dec 7 1998 libpthread.so -rw-r--r-- 1 user1 ladebug 303104 Dec 7 1998 libpthreaddebug.so ./dbglibs: total 0 lrwxrwxrwx 1 user1 ladebug 29 Sep 17 11:24 libpthreaddebug.so@ -> ../applibs/libpthreaddebug.so ./usr: total 8 drwxrwxr-x 2 user1 ladebug 8192 Sep 17 11:36 shlib/ ./usr/shlib: total 0 %If there are other files that need to be moved into applibs, do that as well and then re-observe the file system. In this example, there are not.
Now set the environment variables as indicated:
% env LADEBUG_COREFILE_LIBRARY_PATH=applibs \ LD_LIBRARY_PATH=dbglibs \ ladebug a.out core Welcome to the Ladebug Debugger Version 4.0-n ------------------ object file name: a.out core file name: core Reading symbolic information ...done Core file produced from executable a.out Thread 0x5 terminated at PC 0x3ff8058b448 by signal SEGVIssue the listobj command to ensure the application libraries are coming from applibs/. Any that are not should be found, either from the original system, or unpacked from the tar file but not yet moved into applibs.
(ladebug) listobj section Start Addr End Addr ------------------------------------------------------------------------------ a.out .text 0x120000000 0x120003fff .data 0x140000000 0x140001fff applibs/libpthread.so .text 0x3ff80550000 0x3ff8058bfff .data 0x3ffc0180000 0x3ffc018ffff .bss 0x3ffc0190000 0x3ffc01901af applibs/libmach.so .text 0x3ff80530000 0x3ff8053ffff .data 0x3ffc0170000 0x3ffc0173fff applibs/libexc.so .text 0x3ff807b0000 0x3ff807b5fff .data 0x3ffc0210000 0x3ffc0211fff applibs/libc.so .text 0x3ff80080000 0x3ff8019ffff .data 0x3ffc0080000 0x3ffc0093fff .bss 0x3ffc0094000 0x3ffc00a040fNow debug as usual:
(ladebug) where >0 0x3ff8058b448 in nxm_thread_kill(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libpthread.so #1 0x3ff80578c58 in pthread_kill(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libpthread.so #2 0x3ff8056cd34 in UnknownProcedure3FromFile69(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libpthread.so #3 0x3ff807b22d8 in UnknownProcedure4FromFile1(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libexc.so #4 0x3ff807b3824 in UnknownProcedure17FromFile1(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libexc.so #5 0x3ff807b3864 in exc_unwind(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libexc.so #6 0x3ff807b3af0 in exc_raise_signal_exception(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libexc.so #7 0x3ff8057a328 in UnknownProcedure6FromFile80(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libpthread.so #8 0x3ff800d6a30 in __sigtramp(0x140091c68, 0xb, 0x1, 0x0, 0x0, 0xfffffffffffffcc0) in applibs/libc.so #9 0x120001d94 in mandel_val(cr=0.01, ci=0.16, nmin=0, nmax=255) "mb_pi.c":62 #10 0x12000274c in smp_fill_in_data(raw_mthread=0x11fffe998) "mb_pi.c":338 #11 0x3ff80582068 in thdBase(0x0, 0x2, 0x0, 0x0, 0xff, 0x1) in applibs/libpthread.so (ladebug) quit %
Used alone, kdebug has its own syntax and commands, and allows local nonsymbolic debugging of a running kernel across a serial line. See the kdebug(8) manpage for information about kdebug local kernel debugging.
The kdebug code runs inside the kernel to be debugged on a test system, while the Ladebug debugger runs on a remote system and communicates with kdebug over a serial line or a gateway system.
You use Ladebug commands to start and stop kernel execution, examine variable and register values, and perform other debugging tasks, just as you would when debugging user space programs. The kdebug debugger, not the Ladebug debugger, performs the actual reads and writes to registers, memory, and the image itself (for example, when breakpoints are set).
You use a gateway system when you cannot physically connect the test and build systems. The build system is connected to the gateway system over a network. The gateway system is connected to the test system by a serial communication line.
The following diagram shows the physical connection of the test and build systems (with no gateway):
Build system Serial line Test system (with the Ladebug <-------------------------> (kernel code here) debugger)The following diagram shows the connections when you use a gateway system:
Build system Network Gateway Serial line Test system (with the Ladebug <-----------> system <-------------> (kernel code debugger) with here) kdebug daemon
The serial line provides a physical connection between communication ports on two systems; it consists of a BC16E cable and two H8571-J DECconnect Passive Adapters:
The test system always uses the same communication port for kdebug debugger input and output:
The build or gateway system, whichever is at the other end of the serial line from the test system, uses /etc/remote to specify the device to use for kdebug debugger input and output. Serial communication ports 1 and 2 correspond to device names /dev/tty00 and /dev/tty01, respectively:
The line in /etc/remote that defines /dev/tty00 as the device to use for kdebug debugger input and output is:
kdebug:dv=/dev/tty00:br#9600:pa=none:
For AlphaStation and AlphaServer systems, it is possible to change this definition to /dev/tty01 so the same serial port can be used for remote kernel debugging whether the system is used as a build, gateway, or test system:
kdebug:dv=/dev/tty01:br#9600:pa=none:
The first field, kdebug, is a label and has no significance except it serves as an identifier and "kdebug" is the default name for the serial line used by the debugger for kdebug debugger input and output.
When the line has been connected, enter console mode on the test system by shutting it down; console mode is recognizable by the ">>>" prompt. At the prompt, enter the following command:
>>> set console serial
This will redirect all console input and output to serial communication port 1 (/dev/tty00).
On the build or gateway system, modify the /etc/remote file to define this second line. For example, in order to change the serial line used for kdebug debugger input and output to /dev/tty01 and create a useful label for /dev/tty00 to use for the test system console input and output, replace the original definition for kdebug in /etc/remote on the build or gateway system with:
kdebug:dv=/dev/tty01:br#9600:pa=none: tstsys:dv=/dev/tty00:br#9600:pa=none:
Then on the build or gateway system, in a window separate from the debugger window if on the build system, enter the following command:
% tip tstsys
This separate window can then be used as the console for the test system. When finished, return to the console mode on the test system and enter the following command in the separate console window on the build or gateway system.:
% set console graphicsThen exit out of tip on the build or gateway system by entering a tilde (˜).
The test, build, and (if used) gateway systems must meet the following requirements for kdebug:
Must be running Version 2.0 or higher of the Tru64 UNIX operating system, must have the Kernel Debugging Tools subset loaded, and must have the Kernel Breakpoint Debugger kernel option configured.
Must be running Version 3.2 or higher of the Tru64 UNIX operating system. Also, this system must contain a copy of the kernel code you are testing and, preferably, the source used to build that kernel code.
Must be running Version 2.0 or higher of the Tru64 UNIX operating system, and must have the Kernel Debugging Tools subset loaded.
You can verify the status of each of the system requirements by the using the following commands:
Enter the command:
% uname -a
Enter the command:
% setld -i | grep -i kernel | grep installed
There are two methods to verify this option:
% /sbin/sysconfig -s kdebug
This should indicate that kdebug is loaded and configured.
Look for a file in /sys/config with the same name as the node in question, except all in uppercase. For example, if the name of the node is "mine", look for a file named /sys/config/MINE and search it for a line containing "options KDEBUG". If present, it means the Kernel Breakpoint Debugger kernel option has been configured.
Debugger variables:
On the build system, add the following lines to your .dbxinit file if you need to override the default values (and you choose not to use the corresponding options, described below). Alternatively, you can use these lines within the debugger session, at the (ladebug) prompt:
(ladebug) set $kdebug_host="gateway_system" (ladebug) set $kdebug_line="serial_line" (ladebug) set $kdebug_dbgtty="tty"
$kdebug_dbgtty sets the terminal on the gateway system to display the communication between the build and test systems, which is useful in debugging your setup. To determine the terminal name to supply to the $kdebug_dbgtty variable, enter the tty command in the desired window on the gateway system. By default, $kdebug_dbgtty is null.
Options:
Instead of using debugger variables, you can specify any of the following options on the ladebug command line:
The above three options require the -remote option or its alternative, the -rp kdebug option.
The variables you set in your .dbxinit file will override any options you use on the ladebug command line. In your debugging session, you can still override the .dbxinit variable settings by using the set command at the (ladebug) prompt, prior to issuing the run command.
# sysconfig -r lockmode = 4
Setting this system attribute makes debugging on an SMP system easier.
# ladebug -remote /usr/test/vmunix ... (ladebug) stop in panic [2] stop in panic (ladebug) stop in ttyretype [3] stop in ttyretype
Because Ctrl/C cannot be used as an interrupt, you should set at least one breakpoint if you wish the debugger to gain control of kernel execution. You can set a breakpoint anytime after the execution of the kdebug_bootstrap() routine. Setting a breakpoint prior to the execution of this routine can result in unpredictable behavior. Setting a breakpoint in panic provides for regaining control after a panic and setting a breakpoint in ttyretype provides for returning control to the debugger whenever Ctrl/R is entered at the console.
Note: Pressing Ctrl/C causes the remote debugger to exit, not interrupt as it does during local debugging.
# shutdown -h now
>>> set boot_osflags k
Alternatively, you can enter the following command in step 3 below:
>>> boot -flags k
The boot command can be abbreviated to b and the -flags option can be abbreviated to -fl. The boot command without the -flags option boots the machine using the current value for boot_osflags; with the -flags option, it uses the value specified in the option and does not change the value of the boot_osflags console variable. Other useful commands from the console prompt include show, which lists the values of console variables, and help, which provides information about other commands. For more information about the boot_osflags values, refer to the Compaq Tru64 UNIX System Administration Manual and the Compaq Tru64 UNIX Installation Guide.
(ladebug) run
>>> bootor
>>> boot -flags k
When the breakpoint is dismissed (for example, because you entered a step or cont command to the debugger), processing resumes on all processors.
# tip kdebug
If the command does not return the message "connected," another process, such as a print daemon, might be using the serial line port that you have dedicated to the kdebug debugger. To remedy this condition, do the following:
# ps agxt00
If a process is using tty00, kill that process.
# ps agx | grep kdebugd
If one is running, kill the process.
>>> set boot_osflags k >>> boot
Be sure you defined the Ladebug debugger variables in your .dbxinit file correctly, or specify them correctly on the command line. Determine which pseudoterminal line you ran tip from by issuing the /usr/bin/tty command. For example:
# /usr/bin/tty /dev/ttyp2
The example shows that you are using pseudoterminal /dev/ttyp2. Edit your $HOME/.dbxinit file on the build system as follows:
set $kdebug_dbgtty="/dev/ttyp2"
set $kdebug_host="decosf"
set $kdebug_line=""
When the operating system hangs, you may need to force a crash dump.
Only those users familiar with machine-language programming and executable-file-code structure will find low-level debugging useful.
start_address, end_address / modeIf a symbol precedes the slash (/) in an address expression, you may need to enclose the expression in parentheses. For example:
(ladebug) ($pc), ($pc+12) / iThe following command syntax prints a range of addresses by specifying the beginning address and the total number of memory locations display:
start_address / count modeYou can enter memory addresses in decimal or in hexadecimal by preceding the number with 0x. The mode variable determines how the values are displayed.
The following example shows how to disassemble a range of memory.
(ladebug) 0x120001180, 0x120001185 / i [main:4, 0x120001180] addq zero, 0x1, t0 [main:4, 0x120001184] stl t0, 24(sp) (ladebug) 0x120001180 / 2 i [main:4, 0x120001180] addq zero, 0x1, t0 [main:4, 0x120001184] stl t0, 24(sp) (ladebug)In the preceding example, the same range of addresses was accessed using the start_address command in both the end_address syntax and the / count syntax.
print *(int *)(address)Using the same pointer arithmetic, you can use the assign command to alter the contents of a single address. Use the following syntax:
assign *(int *)(address) = valueThe following example shows how to use pointer arithmetic to examine and change the contents of a single address.
(ladebug) print *(int*)(0x10000000) 4198916 (ladebug) assign *(int*)(0x10000000) = 4194744 (ladebug) print *(int*)(0x10000000) 4194744 (ladebug)
The following example shows Tru64 UNIX Alpha machine-level registers.
(ladebug) printregs $r0 [$v0] = 10 $r1 [$t0] = 1 $r2 [$t1] = 4831844048 $r3 [$t2] = 5368719424 $r4 [$t3] = 0 $r5 [$t4] = 0 $r6 [$t5] = 4396972783304 $r7 [$t6] = 2 $r8 [$t7] = 10 $r9 [$s0] = 337129856 $r10 [$s1] = 337127744 $r11 [$s2] = 4396973344608 $r12 [$s3] = 0 $r13 [$s4] = 5368847640 $r14 [$s5] = 5368753616 $r15 [$s6] = 20 $r16 [$a0] = 1 $r17 [$a1] = 4831835496 $r18 [$a2] = 4831835512 $r19 [$a3] = 4831835848 $r20 [$a4] = 4396981193976 $r21 [$a5] = 5 $r22 [$t8] = 9 $r23 [$t9] = 9 $r24 [$t10] = 4831842472 $r25 [$t11] = 1648 $r26 [$ra] = 4831842828 $r27 [$t12] = 4831842912 $r28 [$at] = 4396981208928 $r29 [$gp] = 5368742064 $r30 [$sp] = 4831835408 $r31 [$zero]= 4831842928 $f0 = 0.1 $f1 = 0 $f2 = 0 $f3 = 0 $f4 = 0 $f5 = 0 $f6 = 0 $f7 = 0 $f8 = 0 $f9 = 0 $f10 = 0 $f11 = 0 $f12 = 0 $f13 = 0 $f14 = 2.035550460865936e-320 $f15 = 4120 $f16 = 0 $f17 = 0 $f18 = 0 $f19 = 0 $f20 = 0 $f21 = 0 $f22 = 0 $f23 = 0 $f24 = 0 $f25 = 0 $f26 = 0 $f27 = 0 $f28 = 0 $f29 = 0 $f30 = 0 $f31 = 0 $pc = 0x120001270 (ladebug)
(ladebug) stop in main [#1: stop in main ] (ladebug) run [1] stopped at [main:4 0x120001180] 4 for (i=1 ; i<3 ; i++) { (ladebug) stepi stopped at [main:4 0x120001184] stl t0, 24(sp) (ladebug) [Return] stopped at [main:5 0x120001188] ldl a0, 24(sp) (ladebug) [Return] stopped at [main:5 0x12000118c] ldq t12, -32664(gp) (ladebug) [Return] stopped at [main:5 0x120001190] bsr ra, (ladebug) [Return] stopped at [factorial:12 0x120001210] ldah gp, 8192(t12) (ladebug)At the machine-instruction level, you can step into, rather than over, a function's prolog. While within a function prolog, you may find that the stack trace, variable scope, and parameter list are not correct. Stepping out of the prolog and into the actual function updates the stack trace and variable information kept by the debugger.
Single-stepping through function prologs that initialize large local variables is slow. As a workaround, use the next command.
UNIX is a registered trademark and The Open Group is a trademark of The Open Group in the United States and/or other countries. All other product names mentioned herein may be the trademarks or registered trademarks of their respective companies.
Confidential computer software. Valid license from Compaq required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.
Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this publication is subject to change without notice and is provided "as is" without warranty of any kind. The entire risk arising out of the use of this information remains with recipient. In no event shall Compaq be liable for any direct, consequential, incidental, special, punitive, or other damages whatsoever (including without limitation, damages for loss of business profits, business interruption, or loss of business information), even if Compaq has been advised of the possibility of such damages.
The limited warranties for Compaq products are exclusively set forth in the documentation accompanying such products. Nothing herein should be construed as constituting a further or additional warranty.