[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference smurf::unix_objsym

Title:Digital UNIX Object File/Symbol Table Notes Conference
Moderator:SMURF::LOWELL
Created:Mon Nov 25 1996
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:71
Total number of notes:314

42.0. "ISSUE 37: Procedure's call-frame weight" by SMURF::LOWELL () Wed Dec 04 1996 15:55

T.RTitleUserPersonal
Name
DateLines
42.1comments on issue 37 from David C. P. LaFrance-LindenSMURF::LOWELLThu Dec 05 1996 16:323
42.2assignedSMURF::LOWELLFri Dec 06 1996 14:531
42.3Details of procedure weightTLE::DMURPHYTue Feb 25 1997 10:14130
    This note covers the review of routine weight indicators in the symbol
    table taken as an action item by Bob Monteleone and myself.

    The informatin in the symbol table's procedure descriptors indicate
    whether a routine is of weight as follows:

    o heavy - bit 26 of the register mask is set ON.

    o light - reg_frame set ON & regoffset set to ra_save

    o null  - reg_frame set ON & regoffset = 26 


    If anyone notes problems/issues with the explanation please
    follow up.


    Here's an exerpt from /usr/include/sym.h to indicate the location of
    reg_frame:

	unsigned gp_prologue : 8; /* byte size of GP prologue */
	unsigned gp_used : 1;	/* true if the procedure uses GP */
	unsigned reg_frame : 1;	/* true if register frame procedure */
	unsigned prof : 1;	/* true if compiled with -pg */

    Here's the dump of a toy program with heavy & null weight routines:

                        ***PROCEDURE DESCRIPTOR TABLE***

    name               prof rfrm  isym iline  iopt   regmask  regoff  fpoff fp
           address     guse gpro lnOff lnLow lnHigh fregmask  frgoff lcloff pc

t.o:

    foo1                 0   1      1     0    -1  0x00000000     26      0 30
      0x0000000000000000 0   0      0     1     5  0x00000000      0      0 26
    foo2                 0   0      5     4    -1  0x04000000    -16     16 30
      0x0000000000000010 1   8      2     7    11  0x00000000      0      0 26
    main                 0   0      9    20    -1  0x04000000    -16     16 30
      0x0000000000000050 1   8      5    13    17  0x00000000      0      0 26

    and the toy program

int foo1() {

    return 1;

}

static int foo2() {

    return foo1();

}

int main() {

    return foo2();

}

     Here's what a lightweigh procedure looks like:

    main                 0   1     20    -1    -1  0x00000000      1      0 30
      0x0000000000000140 0   0     -1    43    48  0x00000000      0      0 26

    We know it's lightweight as r26 in the mawk is off and the regoffset
    ~= 26.

    Here's the GEM code that documents the implementation:

                ! Having set the pcreg field, for heavywieght routines
                ! set bit 26 in the imask, for lightweight routines
                ! set the reg_frame indicator and store the savera
                ! value in the regoffset field. For nullweight routines,
                ! set the reg_frame indicator and store R26 in the
                ! regoffset field.
                !
                if .RTN_BLOCK[GEM_BLK_HEAVYWEIGHT]
                then
                    begin

                    PM = PD[REGMASK];
                    PM[26] = 1;

                    end
                else
                    begin

                    PD[REG_FRAME] = true;

                    if .RTN_BLOCK[GEM_BLK_LIGHTWEIGHT]
                    then
                        ! Lightweight routine
                        !
                        PD[REGOFFSET] = .RTN_BLOCK[GEM_BLK_RA_SAVE]
                    else
                        ! Nullweight routine
                        !
                        PD[REGOFFSET] = GEM_TS_REG_K_R26;


    Here's a better odump:

                        ***PROCEDURE DESCRIPTOR TABLE***

    name               prof rfrm  isym iline  iopt   regmask  regoff  fpoff fp
           address     guse gpro lnOff lnLow lnHigh fregmask  frgoff lcloff pc

testassert.o:
  <stripped>        [0 for 3]
    deb_assert(char*, char*, int) 0   0     18    -1    -1  0x04000e00    -32    
 32
 30
      0x0000000000000000 1   8     -1     4    28  0x00000000      0      0 26
    foo(void)            0   1     19    -1    -1  0x00000000     26      0 30
      0x0000000000000138 0   0     -1    37    41  0x00000000      0      0 26
    main                 0   1     20    -1    -1  0x00000000      1      0 30
      0x0000000000000140 0   0     -1    43    48  0x00000000      0      0 26

    that show's all three weights:

    deb_assert is heavy weight: rfrm = 0 regmask[r26] = 1

    foo is null weight: rfrm = 1 regoffset = 26

    main is light weight: rfrm = 1 regoffset = 1

  
42.4approvedSMURF::LOWELLTue Mar 04 1997 10:447
There haven't been any comments on Dennis' writeup, so it has
been approved.

This description needs to be added to Michelle's spec.  The writeup
is based on existing features of the object/symbol table, so no
tool, header or library changes are required.

42.5Why is this needed?WIBBIN::NOYCEPulling weeds, pickin&#039; stonesMon Mar 10 1997 15:393
Could someone explain why the debugger needs to know
whether a routine is light, heavy, or null in order to
call it?  Compiled code doesn't need to know...
42.6So that we can call the routineVIRRUS::diewaldHere In Soap Opera Central...Mon Mar 10 1997 16:5818
A debugger that wants to be able to call the routine from the
command line needs to know how to set up the call.

For example:

	(ladebug) whatis x
	class Foo {
	  .
	  .
	  void dump (void);  // dumper routine for class
	}
	(ladebug) call x->dump()
	
Since we want to be able to do this with any arbitrary procedure,
we have to know how the compiler set up the routine.

					Jeff Diewald
					Ladebug team
42.7ADA9X::BRETTTue Mar 11 1997 07:444
But the caller's set-up for the call is, if I understand Bill and the calling
standard properly, independent of the called routines 'weight'.

/Bevin
42.8TLE::DMURPHYFri Apr 18 1997 11:5120
 > Could someone explain why the debugger needs to know
 > whether a routine is light, heavy, or null in order to
 > call it?  Compiled code doesn't need to know...

    Bill, I seem to remember looking at a debugger stack trace related to a C++
    exception. I thought at the time that proper understanding of a functions
    weight would have helped.

    The reason for documenting the function weight is that its being
    written to the object files by the compilers, presumably its being
    read by somone. 

    The proper place for any information represented in the object file
    is in this document.

							Dennis

    

    
42.9SMURF::LOWELLMon Apr 21 1997 13:252
Dennis' writeup on determining call frame weight has been
added to the object spec.  This issue is now closed.