Пример #1
0
/*
 * bit_field_class - dump info
 */
static void bit_field_class( unsigned_8 *buff, bool bit )
/*******************************************************/
{
    unsigned_8  *ptr;
    unsigned_16 index;
    char        name[256];

    ptr = buff+3;
    Wdputs( "          field locator = " );
    ptr = Dump_location_expression( ptr, "            " );
    if( bit ) {
        ptr += 2;
    }
    ptr = Get_type_index( ptr, &index );
    Get_local_name( name, ptr, buff );
    Wdputs( "          name = \"" );
    Wdputs( name );
    Wdputs( "\"  type idx = " );
    Putdec( index );
    Wdputslc( "\n          attribute = " );
    attribute_byte( buff[2] );
    if( bit ) {
        Wdputslc( "  start bit = " );
        ptr++;
        Puthex( *ptr, 2 );
        Wdputslc( "  bit size = " );
        ptr++;
        Puthex( *ptr, 2 );
    }
    Wdputslc( "\n" );
}
Пример #2
0
/*
 * bit_field_struct - dump info
 */
static void bit_field_struct( unsigned_8 *buff, unsigned_8 size, bool bit )
/*************************************************************************/
{
    unsigned_8  *ptr;
    unsigned_16 index;
    char        name[256];

    ptr = buff+2+size;
    if( bit ) {
        ptr += 2;
    }
    ptr = Get_type_index( ptr, &index );
    Get_local_name( name, ptr, buff );
    Wdputs( "          \"" );
    Wdputs( name );
    Wdputs( "\"  offset = " );
    ptr = buff+2;
    Puthex( *ptr, 2*size );
    Wdputs( "  type idx = " );
    Putdec( index );
    if( bit ) {
        Wdputslc( "\n        start bit = " );
        ptr++;
        Puthex( *ptr, 2 );
        Wdputslc( "  bit size = " );
        ptr++;
        Puthex( *ptr, 2 );
    }
    Wdputslc( "\n" );
}
Пример #3
0
/*
 * base_type_index - dump info
 */
static unsigned_8 *base_type_index( unsigned_8 *buff )
/****************************************************/
{
    unsigned_16 index;
    unsigned_8  *ptr;

    Wdputs( "   base type idx = " );
    ptr = Get_type_index( buff, &index );
    Putdec( index );
    Wdputslc( "\n" );
    return( ptr );
}
Пример #4
0
/*
 * dump_rtn386 - dump a near or far routine defn (386)
 */
static void dump_rtn386( unsigned_8 *buff )
/*****************************************/
{
    int         pro,epi;
    unsigned_32 ret_off;
    unsigned_8  *ptr;
    int         num_parms;
    unsigned_16 index;
    char        name[256];
    int         i;

    dump_block( buff, TRUE );

    ptr = buff + sizeof( block_386 );
    pro = *ptr++;
    epi = *ptr++;
    Wdputs( "          prologue size = " );
    Putdec( pro );
    Wdputs( ",  epilogue size = " );
    Putdec( epi );
    Wdputslc( "\n" );

    ret_off = *(unsigned_32 *) ptr;
    ptr += sizeof( unsigned_32 );
    Wdputs( "          return address offset (from bp) = " );
    Puthex( ret_off, 8 );
    Wdputslc( "\n" );

    ptr = Get_type_index( ptr, &index );
    Wdputs( "          return type:  " );
    Putdec( index );
    Wdputslc( "\n" );

    Wdputs( "          return value: " );
    ptr = Dump_location_expression( ptr, "            " );

    num_parms = *ptr++;
    for( i = 0; i < num_parms; i++ ) {
        Wdputs( "          Parm " );
        Putdec( i );
        Wdputs( ": " );
        ptr = Dump_location_expression( ptr, "            " );
    }
    Get_local_name( name, ptr, buff );
    Wdputs( "          Name = \"" );
    Wdputs( name );
    Wdputslc( "\"\n" );

} /* dump_rtn386 */
Пример #5
0
/*
 * near_far_proc - dump info
 */
static void near_far_proc( unsigned_8 *buff )
/*******************************************/
{
    unsigned_8      *ptr;
    unsigned_16     index;
    unsigned_8      num_parms;

    ptr = buff + 2;
    Wdputs( "          return type = " );
    num_parms = buff[0] - 4;
    if( *ptr & 0x80 ) {
        num_parms--;
    }
    ptr = Get_type_index( ptr, &index );
    Putdec( index );
    ptr++;
    param_type_index( num_parms, ptr );
}
Пример #6
0
/*
 * param_type_index - dump info
 */
static void param_type_index( unsigned_8 num_params, unsigned_8 *ptr )
/********************************************************************/
{
    unsigned_8  i;
    unsigned_16 index;

    if( *ptr & 0x80 ) {
        num_params /= 2;
    }
    for( i = 0; i < num_params; i++ ) {
        Wdputslc( "\n" );
        Wdputs( "            param " );
        Putdec( i+1 );
        Wdputs( ":  type idx = " );
        ptr = Get_type_index( ptr, &index );
        Putdec( index );
    }
    Wdputslc( "\n" );
}
Пример #7
0
/*
 * dump_locals - dump all local variable information
 */
static void dump_locals( mod_info *mi )
/*************************************/
{
    int         i;
    unsigned_32 *offs;
    int         cnt;
    unsigned_32 coff;
    unsigned_8  buff[256];
    char        name[256];
    set_base    *sb;
    set_base386 *sb386;
    unsigned_8  *ptr;
    addr32_ptr  *p32;
    addr48_ptr  *p48;
    unsigned_16 index;

    cnt = mi->di[DMND_LOCALS].u.entries;
    if( cnt == 0 ) {
        return;
    }
    Wdputslc( "\n" );
    Wdputslc( "   *** Locals ***\n" );
    Wdputslc( "   ==============\n" );

    offs = alloca( (cnt+1) * sizeof( unsigned_32 ) );
    if( offs == NULL ) {
        Wdputslc( "Error! Not enough stack.\n" );
        longjmp( Se_env, 1 );
    }
    Wlseek( Curr_sectoff + mi->di[DMND_LOCALS].info_off );
    Wread( offs, (cnt+1) * sizeof( unsigned_32 ) );
    for( i = 0; i < cnt; i++ ) {
        coff = 0;
        Wdputs( "      Data " );
        Putdec( i );
        Wdputs( ":  offset " );
        Puthex( offs[i], 8 );
        Wdputslc( "\n" );
        for( ;; ) {
            Wlseek( coff + Curr_sectoff + offs[i] );
            Wread( buff, sizeof( buff ) );
            Wdputs( "        " );
            Puthex( coff, 4 );
            Wdputs( ": " );
            switch( buff[1] ) {
            case MODULE:
                Wdputslc( "MODULE\n" );
                ptr = buff+2;
                p32 = (addr32_ptr *)ptr;
                ptr += sizeof( addr32_ptr );
                ptr = Get_type_index( ptr, &index );
                Get_local_name( name, ptr, buff );
                Wdputs( "          \"" );
                Wdputs( name );
                Wdputs( "\"  addr = " );
                Puthex( p32->segment, 4 );
                Wdputc( ':' );
                Puthex( p32->offset, 4 );
                Wdputs( ", type = " );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case LOCAL:
                Wdputslc( "LOCAL\n" );
                ptr = buff+2;
                Wdputs( "          address: " );
                ptr = Dump_location_expression( ptr, "            " );
                ptr = Get_type_index( ptr, &index );
                Get_local_name( name, ptr, buff );
                Wdputs( "          name = \"" );
                Wdputs( name );
                Wdputs( "\",  type = " );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case MODULE_386:
                Wdputslc( "MODULE_386\n" );
                ptr = buff+2;
                p48 = (addr48_ptr *)ptr;
                ptr += sizeof( addr48_ptr );
                ptr = Get_type_index( ptr, &index );
                Get_local_name( name, ptr, buff );
                Wdputs( "          \"" );
                Wdputs( name );
                Wdputs( "\" addr = " );
                Puthex( p48->segment, 4 );
                Wdputc( ':' );
                Puthex( p48->offset, 8 );
                Wdputs( ",  type = " );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case MODULE_LOC:
                Wdputslc( "MODULE_LOC\n" );
                ptr = buff+2;
                Wdputs( "          address: " );
                ptr = Dump_location_expression( ptr, "            " );
                ptr = Get_type_index( ptr, &index );
                Get_local_name( name, ptr, buff );
                Wdputs( "          name = \"" );
                Wdputs( name );
                Wdputs( "\",  type = " );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case BLOCK:
                Wdputslc( "BLOCK\n" );
                dump_block( buff, FALSE );
                break;
            case NEAR_RTN:
                Wdputslc( "NEAR_RTN\n" );
                dump_rtn( buff );
                break;
            case FAR_RTN:
                Wdputslc( "FAR_RTN\n" );
                dump_rtn( buff );
                break;
            case BLOCK_386:
                Wdputslc( "BLOCK_386\n" );
                dump_block( buff, TRUE );
                break;
            case NEAR_RTN_386:
                Wdputslc( "NEAR_RTN_386\n" );
                dump_rtn386( buff );
                break;
            case FAR_RTN_386:
                Wdputslc( "FAR_RTN_386\n" );
                dump_rtn386( buff );
                break;
            case MEMBER_SCOPE:
                Wdputslc( "MEMBER_SCOPE\n" );
                index = 5;
                ptr = buff+2;
                Wdputs( "          parent offset = " );
                Puthex( *ptr, 4 );
                ptr += 2;
                if( *ptr & 0x80 ) {
                    index = 6;
                }
                Wdputs( "  class type = " );
                ptr = Get_type_index( ptr, &index );
                Putdec( index );
                if( buff[0] > index ) {
                    Wdputslc( "\n          object ptr type = " );
                    Puthex( *ptr++, 2 );
                    Wdputs( "  object loc = " );
                    Dump_location_expression( ptr, "            " );
                }
                Wdputslc( "\n" );
                break;
            case ADD_PREV_SEG:
                Wdputslc( "ADD_PREV_SEG\n" );
                Wdputs( "          segment increment = " );
                Puthex( *(buff+2), 4 );
                Wdputslc( "\n" );
                break;
            case SET_BASE:
                Wdputslc( "SET_BASE\n" );
                sb = (set_base *) buff;
                Wdputs( "          base = " );
                Puthex( sb->seg, 4 );
                Wdputc( ':' );
                Puthex( sb->off, 4 );
                Wdputslc( "\n" );
                break;
            case SET_BASE_386:
                Wdputslc( "SET_BASE_386\n" );
                sb386 = (set_base386 *) buff;
                Wdputs( "          base = " );
                Puthex( sb386->seg, 4 );
                Wdputc( ':' );
                Puthex( sb386->off, 8 );
                Wdputslc( "\n" );
                break;
            }
            coff += buff[0];
            if( coff >= (offs[i+1] - offs[i]) ) {
                break;
            }
        }
    }

} /* dump_locals */
Пример #8
0
/*
 * Dump_types - dump all typing information
 */
void Dmp_type( int cnt, unsigned_32 *offs )
/*****************************************/
{
    int         i;
    addr32_ptr  *p32;
    addr48_ptr  *p48;
    unsigned_8  *ptr;
    unsigned_16 index;
    unsigned_16 curr_index;
    unsigned_32 coff;
    char        name[256];
    unsigned_8  buff[256];

    for( i = 0; i < cnt; i++ ) {
        coff = 0;
        Wdputs( "      Data " );
        Putdec( i );
        Wdputs( ":  offset " );
        Puthex( offs[i], 8 );
        Wdputslc( "\n" );
        curr_index = 0;
        for( ;; ) {
            Wlseek( coff + Curr_sectoff + offs[i] );
            Wread( buff, sizeof( buff ) );
            Wdputs( "        " );
            Puthex( coff, 4 );
            Wdputs( ": " );
            ptr = buff+2;
            switch( buff[1] ) {
            case SCALAR:
                StartType( "SCALAR", ++curr_index );
                ptr = buff+3;
                Get_local_name( name, ptr, buff );
                Wdputs( "          \"" );
                Wdputs( name );
                Wdputs( "\"  scalar type = " );
                scalar_type( buff[2] );
                Wdputslc( "\n" );
                break;
            case SCOPE:
                StartType( "SCOPE", ++curr_index);
                Get_local_name( name, ptr, buff );
                Wdputs( "          \"" );
                Wdputs( name );
                Wdputslc( "\"\n" );
                break;
            case NAME:
                StartType( "NAME", ++curr_index);
                ptr = Get_type_index( ptr, &index );
                ptr = Get_type_index( ptr, &index );
                Get_local_name( name, ptr, buff );
                Wdputs( "          \"" );
                Wdputs( name );
                Wdputs( "\"  type idx = " );
                Putdec( index );
                Wdputs( "  scope idx = " );
                ptr = Get_type_index( buff+2, &index );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case CUE_TABLE:
                Wdputs( "cue table offset=" );
                Puthex( *(unsigned_32 *)ptr, 8 );
                Wdputslc( "\n" );
                break;
            case TYPE_EOF:
                return;
            case BYTE_INDEX:
                StartType( "BYTE_INDEX ARRAY", ++curr_index);
                array_index( ptr, 1 );
                break;
            case WORD_INDEX:
                StartType( "WORD_INDEX ARRAY", ++curr_index);
                array_index( ptr, 2 );
                break;
            case LONG_INDEX:
                StartType( "LONG_INDEX ARRAY", ++curr_index);
                array_index( ptr, 4 );
                break;
            case TYPE_INDEX:
                StartType( "TYPE_INDEX ARRAY", ++curr_index);
                Wdputs( "          index type = " );
                ptr = Get_type_index( ptr, &index );
                Putdec( index );
                base_type_index( ptr );
                break;
            case DESC_INDEX:
                StartType( "DESC_INDEX ARRAY", ++curr_index);
                desc_array( ptr, false );
                break;
            case DESC_INDEX_386:
                StartType( "DESC_INDEX ARRAY", ++curr_index);
                desc_array( ptr, true );
                break;
            case BYTE_RANGE:
                StartType( "BYTE_RANGE", ++curr_index);
                range( ptr, 1 );
                break;
            case WORD_RANGE:
                StartType( "WORD_RANGE", ++curr_index);
                range( ptr, 2 );
                break;
            case LONG_RANGE:
                StartType( "LONG_RANGE", ++curr_index);
                range( ptr, 4 );
                break;
            case PTR_NEAR:
                StartType( "NEAR PTR", ++curr_index);
                Wdputs( "       " );
                near_ptr( buff );
                break;
            case PTR_FAR:
                StartType( "FAR PTR", ++curr_index);
                Wdputs( "       " );
                base_type_index( ptr );
                break;
            case PTR_HUGE:
                StartType( "HUGE PTR", ++curr_index);
                Wdputs( "       " );
                base_type_index( ptr );
                break;
            case PTR_NEAR_DEREF:
                StartType( "NEAR_DEREF PTR", ++curr_index);
                Wdputs( "       " );
                near_ptr( buff );
                break;
            case PTR_FAR_DEREF:
                StartType( "FAR_DEREF PTR", ++curr_index);
                Wdputs( "       " );
                base_type_index( ptr );
                break;
            case PTR_HUGE_DEREF:
                StartType( "HUGE_DEREF PTR", ++curr_index);
                Wdputs( "       " );
                base_type_index( ptr );
                break;
            case PTR_NEAR386:
                StartType( "NEAR386 PTR", ++curr_index);
                Wdputs( "       " );
                near_ptr( buff );
                break;
            case PTR_FAR386:
                StartType( "FAR386 PTR", ++curr_index);
                Wdputs( "       " );
                base_type_index( ptr );
                break;
            case PTR_NEAR386_DEREF:
                StartType( "NEAR386_DEREF PTR", ++curr_index);
                Wdputs( "       " );
                near_ptr( buff );
                break;
            case PTR_FAR386_DEREF:
                StartType( "FAR386_DEREF PTR", ++curr_index);
                Wdputs( "\n       " );
                base_type_index( ptr );
                break;
            case CLIST:
                StartType( "ENUM_LIST", ++curr_index);
                Wdputs( "          number of consts = " );
                Puthex( *ptr, 4 );
                Wdputs( "   scalar type = " );
                scalar_type( buff[4] );
                Wdputslc( "\n" );
                break;
            case CONST_BYTE:
                Wdputslc( "CONST_BYTE\n" );
                enum_const( buff, 1 );
                break;
            case CONST_WORD:
                Wdputslc( "CONST_WORD\n" );
                enum_const( buff, 2 );
                break;
            case CONST_LONG:
                Wdputslc( "CONST_LONG\n" );
                enum_const( buff, 4 );
                break;
            case FLIST:
                StartType( "FIELD_LIST", ++curr_index);
                Wdputs( "          number of fields = " );
                Puthex( *ptr, 4 );
                if( buff[0] > 4 ) {
                    Wdputs( "   size = " );
                    ptr += 2;
                    Puthex( *ptr, 8 );
                }
                Wdputslc( "\n" );
                break;
            case FIELD_BYTE:
                Wdputslc( "FIELD_BYTE\n" );
                bit_field_struct( buff, 1, false );
                break;
            case FIELD_WORD:
                Wdputslc( "FIELD_WORD\n" );
                bit_field_struct( buff, 2, false );
                break;
            case FIELD_LONG:
                Wdputslc( "FIELD_LONG\n" );
                bit_field_struct( buff, 4, false );
                break;
            case BIT_BYTE:
                Wdputslc( "BIT_BYTE\n" );
                bit_field_struct( buff, 1, true );
                break;
            case BIT_WORD:
                Wdputslc( "BIT_WORD\n" );
                bit_field_struct( buff, 2, true );
                break;
            case BIT_LONG:
                Wdputslc( "BIT_LONG\n" );
                bit_field_struct( buff, 4, true );
                break;
            case FIELD_CLASS:
                Wdputslc( "FIELD_CLASS\n" );
                bit_field_class( buff, false );
                break;
            case BIT_CLASS:
                Wdputslc( "BIT_CLASS\n" );
                bit_field_class( buff, true );
                break;
            case INHERIT_CLASS:
                Wdputslc( "INHERIT_CLASS\n" );
                Wdputs( "          adjust locator = " );
                ptr = Dump_location_expression( ptr, "            " );
                Wdputs( "          ancestor type = " );
                Get_type_index( ptr, &index );
                Putdec( index );
                Wdputslc( "\n" );
                break;
            case PNEAR:
                StartType( "NEAR PROC", ++curr_index);
                near_far_proc( buff );
                break;
            case PFAR:
                StartType( "FAR PROC", ++curr_index);
                near_far_proc( buff );
                break;
            case PNEAR386:
                StartType( "NEAR386 PROC", ++curr_index);
                near_far_proc( buff );
                break;
            case PFAR386:
                StartType( "FAR386 PROC", ++curr_index);
                near_far_proc( buff );
                break;
            case EXT_PARMS:
                Wdputslc( "EXT_PARMS\n" );
                param_type_index( (unsigned_8)buff[0]-2, ptr );
                break;
            case CHAR_BYTE:
                StartType( "CHAR_BYTE", ++curr_index);
                Wdputs( "        length = " );
                Puthex( *ptr, 2 );
                Wdputslc( "\n" );
                break;
            case CHAR_WORD:
                StartType( "CHAR_WORD", ++curr_index);
                Wdputs( "        length = " );
                Puthex( *ptr, 4 );
                Wdputslc( "\n" );
                break;
            case CHAR_LONG:
                StartType( "CHAR_LONG", ++curr_index);
                Wdputs( "        length = " );
                Puthex( *ptr, 8 );
                Wdputslc( "\n" );
                break;
            case CHAR_IND:
                StartType( "CHAR_IND", ++curr_index);
                Wdputs( "       scalar type = " );
                scalar_type( buff[2] );
                p32 = (addr32_ptr *)ptr;
                Puthex( p32->segment, 4 );
                Wdputc( ':' );
                Puthex( p32->offset, 4 );
                Wdputslc( "\n" );
                break;
            case CHAR_IND_386:
                StartType( "CHAR_IND_386", ++curr_index);
                Wdputs( "       scalar type = " );
                scalar_type( buff[2] );
                p48 = (addr48_ptr *)ptr;
                Puthex( p48->segment, 4 );
                Wdputc( ':' );
                Puthex( p48->offset, 8 );
                Wdputslc( "\n" );
                break;
            case CHAR_LOCATION:
                StartType( "CHAR_LOC", ++curr_index);
                Wdputs( "       scalar type = " );
                scalar_type( buff[2] );
                Wdputs( "          size locator = " );
                ptr = Dump_location_expression( ptr + 1, "            " );
                Wdputslc( "\n" );
                break;
            }
            coff += buff[0];
            if( coff >= (offs[i+1] - offs[i]) ) {
                break;
            }
        }
    }

} /* Dmp_type */