Summary: GDB + DEC Fortran, at last!

From: <jebroderick_at_CCGATE.HAC.COM>
Date: Thu, 17 Jul 97 17:12:47 PST8

     The patch file at the end of this email is intended for
     gdb-4.15.1/gdb/mdebugread.c. It must be used in conjuction with
     Colle Cristophe's 4.15.1 alpha patches from about two years ago.
     
     Disclaimers: 1. standard GNU disclaimers apply
                   2. I don't have 4.16, so I don't know if it will work
                      there.
                   3. Our fortran is some field test version that's pretty
                      old.
                   4. Our OS is 3.2C
                   5. The code doesn't follow GNU coding standards
                   6. This probably breaks FORTRAN support for other
                      platforms/compilers
                   7. We don't use FORTRAN structures or F90.
     
     
     That said, my coworkers and I now have about a week's experience with
     these patches and think the bugs are shaken out.
     
     1. To set a break point in a FORTRAN routine (note underbar):
     
        break mysub_
     
     2. To set a break at a FORTRAN entry point:
     
        break myentry_
     
     3. To view a common variable when in a FORTRAN routine
        (note caps):
     
        print MYCOMVAR
     
     4. To view a local var in FORTRAN (note lower case):
     
        print mylocvar
     
     5. To view all variables when in a FORTRAN routine:
     
        info locals
     
        -> Common blocks shown as void, but members shown with above
           capitalization, as well as locals.
     
     The capitalization scheme follows our local coding standard, and
     makes everything work with ddd's cursor over the variable hints.
     Change it if you don't like it! (Take out my initials if you don't
     like them either!)
     
     Jim Broderick
     Hughes Missile Systems Co.
     jebroderick_at_ccgate.hac.com
     
     Sorry, our email system enforces 80 columns!!!!!
     
     % diff mdebugread.c mdebugread.orig
     
     131,140d130
     <
     < /*** JEB start ***/
     <
     < static void fixup_fortran_commons(struct symtab *st);
     < static void make_commons_void(struct symtab *st);
     <
     < /*** JEB end ***/
     <
     <
     <
     443,449d432
     < /*** JEB start ***/
     <
     < fixup_fortran_commons(pst->symtab);
     < make_commons_void(pst->symtab);
     <
     < /*** JEB end ***/
     <
     774,791d756
     <
     < /*** JEB start ***/
     <
     < /* if new symbol class is Bss and language is FORTRAN: make it
     lower case. */
     <
     < if ((sh->sc == scBss) && (SYMBOL_LANGUAGE(s) == language_fortran))
     {
     < char *c = s->ginfo.name;
     < int i = 0;
     < do {
     < if (c[i] == '\000') break;
     < if ((c[i] >= 'A') && (c[i] <= 'Z')) c[i] += 32;
     < i++;
     < } while (1);
     <
     < }
     <
     < /*** JEB end ***/
     <
     817,850d781
     <
     <
     < /*** JEB start ***/
     <
     < /* for fortran common blocks, take the elements
     < and add them as symbols to the enclosing block.
     < These symbols will need address fixups later */
     <
     < if ( (top_stack->cur_st->language == language_fortran) &&
     < (sh->sc == scCommon)) {
     <
     < int i,j,k;
     < struct symbol *s;
     < struct block *b = top_stack->cur_block;
     <
     < /* loop over fields in last symbol, and make new symbols */
     <
     < i = b->nsyms-1; /* i = the common symbol */
     < k = b->sym[i]->type->nfields; /* k = number to add */
     < for (j=0; j < k; j++) {
     < s = new_symbol (b->sym[i]->type->fields[j].name);
     < SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
     < SYMBOL_CLASS (s) = LOC_STATIC;
     < SYMBOL_TYPE (s) = b->sym[i]->type->fields[j].type;
     < SYMBOL_VALUE_BYTES (s) = b->sym[i]->ginfo.name;
     < s->line = j;
     < add_symbol (s, b);
     < b = top_stack->cur_block;
     < }
     < }
     <
     < /*** JEB end ***/
     <
     <
     923,935d853
     <
     < /*** JEB start ***/
     <
     < /* don't do anything for an entry point
     < the user can still break on the entry name, because
     < it's in the psymtab, but, the entry statement now
     < just looks like a line in the subroutine */
     <
     < else if (top_stack->cur_st->language == language_fortran)
     < break;
     <
     < /*** JEB end ***/
     <
     4335,4424d4252
     <
     <
     < /*** JEB start ***/
     <
     < /******************* fixup_fortran_commons() **********************
     <
     < At the end of forming a symbol table, this routine loops
     < over all the blocks, and fixes the addresses of the symbols
     < created in parse_symbol out of the common symbol members
     <
     < *******************************************************************/
     <
     <
     < static void fixup_fortran_commons(struct symtab *st) {
     <
     < int i,j,k,maxblocks, maxsyms, maxfields;
     <
     < struct block *b;
     < struct symbol *c;
     < struct symbol *s;
     <
     < if (st->language != language_fortran) return;
     <
     < maxblocks = st->blockvector->nblocks;
     <
     < for (i=2; i < maxblocks; i++) { /** i loops over
     blocks in symtable **/
     <
     < b = st->blockvector->block[i]; /** b = block[i]
     **/
     < maxsyms = b->nsyms;
     <
     < for (j=0; j < maxsyms; j++) { /** j
     loops over syms in block **/
     <
     < c = b->sym[j]; /** c =
     (common) symbol[j] **/
     < if (c->type->code != TYPE_CODE_STRUCT) continue;
     < maxfields = c->type->nfields;
     <
     < for (k=0; k < maxfields; k++) { /**
     k loops over fields in common symbol **/
     <
     < s = b->sym[j+k+1]; /**
     s is the child symbol to fix up **/
     <
     < SYMBOL_VALUE_ADDRESS (s) = SYMBOL_VALUE_ADDRESS(c);
     < SYMBOL_VALUE_ADDRESS (s) +=
     (c->type->fields[s->line].bitpos)/8;
     < s->line = 0;
     < }
     <
     < }
     <
     < }
     <
     < }
     <
     < /*********************** make_commons_void() **********************
     <
     < Now that all the symbols created from common elements have been
     < fixed up, make the common symbols void so they don't choke the
     < fortran parser.
     <
     < *******************************************************************/
     <
     < static void make_commons_void(struct symtab *st) {
     <
     < int i,j,maxblocks, maxsyms;
     <
     < struct block *b;
     < struct symbol *c;
     <
     < if (st->language != language_fortran) return;
     <
     < maxblocks = st->blockvector->nblocks;
     <
     < for (i=2; i < maxblocks; i++) { /** i loops over
     blocks in symtable **/
     <
     < b = st->blockvector->block[i]; /** b = block[i]
     **/
     < maxsyms = b->nsyms;
     <
     < for (j=0; j < maxsyms; j++) { /** j
     loops over syms in block **/
     <
     < c = b->sym[j]; /** c =
     (common) symbol[j] **/
     < if (c->type->code == TYPE_CODE_STRUCT)
     < c->type->code = TYPE_CODE_VOID;
     <
     < }
     <
     < }
     <
     < }
     <
     <
     < /*** JEB end ***/
     <
     
     
Received on Fri Jul 18 1997 - 02:35:30 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT