Пример #1
0
static size_t GetNameBuffAttr( drmem_hdl entry, char *buff, size_t length, dw_atnum attrib )
/******************************************************************************************/
{
    drmem_hdl   abbrev;
    dw_formnum  form;

    abbrev = DWRSkipTag( &entry ) + 1;
    if( DWRScanForAttrib( &abbrev, &entry, attrib ) ) {
        form = DWRVMReadULEB128( &abbrev );
        switch( form ) {
        case DW_FORM_string:
            length = DWRVMGetStrBuff( entry, buff, length );
            break;
        case DW_FORM_strp:
            {
                unsigned_32 offset;
                drmem_hdl   dbgsec_str;
    
                offset = ReadConst( DW_FORM_data4, entry );
                dbgsec_str = DWRCurrNode->sections[DR_DEBUG_STR].base + offset;
                length = DWRVMGetStrBuff( dbgsec_str, buff, length );
            }
            break;
        default:
            DWREXCEPT( DREXCEP_BAD_DBG_INFO );
            length = 0;
        }
    } else {
        length = 0;
    }
    return( length );
}
Пример #2
0
static dr_handle ScopePop( dr_scope_stack *stack )
/************************************************/
{
    if( stack->free <= 0 ) {
        DWREXCEPT( DREXCEP_DWARF_LIB_FAIL );
    }

    stack->free -= 1;
    return( stack->stack[stack->free] );
}
Пример #3
0
uint_32 DWRStackPop(                        // POP ITEM OFF THE STACK
    dr_stack *stk )                         // -- stack to pop off of
/*************************/
{
    if( stk->free == 0 ) {
        DWREXCEPT( DREXCEP_DWARF_LIB_FAIL );
    }

    stk->free -= 1;
    return stk->stack[stk->free];
}
Пример #4
0
static void GetMoreBranches( void )
/*********************************/
// make a larger array to hold branch pointers in.
{
    page_entry      **branches;
    unsigned        alloc_size;

    alloc_size = NumBranches * sizeof( page_entry * );
    NumBranches = NumBranches * 2;   // double the # of pointers.
    if( NumBranches > SEG_LIMIT ) {
        DWREXCEPT( DREXCEP_OUT_OF_VM );
    }
    branches = DWRALLOC( alloc_size * 2 );
    memcpy( branches, PageTab, alloc_size );
    memset( (char *)branches + alloc_size, 0, alloc_size ); // null pointers
    DWRFREE( PageTab );
    PageTab = branches;
}
Пример #5
0
extern dr_handle DWRVMAlloc( unsigned long len, int sect )
/********************************************************/
{
    alloc_struct *nChunk;

    if( len == 0 ) {
        return( 0 );
    }

    nChunk = (alloc_struct *)DWRALLOC( len - 1 + sizeof( alloc_struct ) );
    if( nChunk == NULL ) {
        DWREXCEPT( DREXCEP_OUT_OF_MMEM );
        return( 0 );
    }

    nChunk->next = AllocHead;
    AllocHead = nChunk;

    DWRSEEK( DWRCurrNode->file, sect, 0 );
    DWRREAD( DWRCurrNode->file, sect, nChunk->data, len );

    return( (dr_handle)nChunk->data );
}
Пример #6
0
void DRWalkARange( DRARNGWLK callback, void *data )
/*************************************************/
{
    dr_arange_data      arange;
    arange_header       header;
    drmem_hdl           base;
    drmem_hdl           pos;
    drmem_hdl           finish;
    uint_32             tuple_size;
    pointer_int         aligned_addr;
    pointer_int         addr;
    bool                wat_producer;
    bool                zero_padding = true;

    base = DWRCurrNode->sections[DR_DEBUG_INFO].base;
    pos = DWRCurrNode->sections[DR_DEBUG_ARANGES].base;
    finish = pos + DWRCurrNode->sections[DR_DEBUG_ARANGES].size;
    while( pos < finish ) {
        DWRVMRead( pos, &header, sizeof( header ) );
        pos += sizeof( header );
        if( DWRCurrNode->byte_swap ) {
            SWAP_32( header.len );
            SWAP_16( header.version );
            SWAP_32( header.dbg_pos );
        }
        if( header.version != DEBUG_ARANGES_VERSION )
            DWREXCEPT( DREXCEP_BAD_DBG_VERSION );
        arange.dbg = base + header.dbg_pos;
        arange.addr_size = header.addr_size;
        arange.seg_size = header.seg_size;
        arange.is_start = true;   /* start of bunch */
        tuple_size = ( header.addr_size + header.seg_size + header.addr_size );
        /* Open Watcom prior to 1.4 didn't align tuples properly; unfortunately
         * it may be hard to tell if debug info was generated by Watcom!
         */
        /* NB: The writers of the DWARF 2/3 standard clearly didn't think very hard
         * about segmented architectures. If tuple size is 10 (32-bit offset, 16-bit
         * segment, 32-bit size) we assume the data was generated by our tools and
         * no alignment padding was used.
         */
        wat_producer = ( DWRCurrNode->wat_producer_ver > VER_NONE ) || ( tuple_size == 10 );
        addr = (pointer_int)pos;
        aligned_addr = (addr + tuple_size - 1) & ~(tuple_size - 1);
        if( aligned_addr != addr ) {
            /* try reading the padding; if it's nonzero, assume it's not there */
            if( DWRReadInt( pos, header.addr_size ) != 0 )
                zero_padding = false;
            if( header.seg_size && DWRReadInt( pos + header.addr_size, header.seg_size ) != 0 )
                zero_padding = false;
            if( !wat_producer && zero_padding ) {
                pos = (drmem_hdl)aligned_addr;
            }
        }
        for( ;; ) {
            arange.addr = DWRReadInt( pos, header.addr_size );
            pos += header.addr_size;
            if( header.seg_size != 0 ) {
                arange.seg = (uint_16)DWRReadInt( pos, header.seg_size );
                pos += header.seg_size;
            } else { /* flat */
                arange.seg = 0;
            }
            arange.len = DWRReadInt( pos, header.addr_size );
            pos += header.addr_size;
            if( arange.addr == 0 && arange.seg == 0 && arange.len == 0 )
                break;
            if( !callback( data, &arange ) )
                break;
            arange.is_start = false;
        }
    }
}