Esempio n. 1
0
static void DwarfAddLines( lineinfo *info )
/*****************************************/
// calculate the amount of space needed to hold all of the line # info.
{
    ln_off_pair _WCUNALIGNED *lineptr;
    unsigned_32         dwsize;
    unsigned_8          buff[ 3 + 2 * MAX_LEB128 ];
    dw_linenum_delta    linedelta;
    dw_addr_delta       addrdelta;
    ln_off_386          prevline;
    unsigned            size;
    unsigned            item_size;

    prevline.off = 0;
    prevline.linnum = 1;
    if( FmtData.type & MK_16BIT ) {
        dwsize = 13;    // start and end sequence with 16-bit offset
    } else {
        dwsize = 15;    // start and end sequence with 32-bit offset
    }
    if( (FmtData.type & MK_SEGMENTED) == 0 ) {
        dwsize -= 5;    // size of LNE_segment burst
    }
    lineptr = (ln_off_pair *)info->data;
    if( info->size & LINE_IS_32BIT ) {
        item_size = sizeof( ln_off_386 );
    } else {
        item_size = sizeof( ln_off_286 );
    }
    for( size = info->size & ~LINE_IS_32BIT; size > 0; size -= item_size ) {
        if( info->size & LINE_IS_32BIT ) {
            linedelta = (signed_32)lineptr->_386.linnum - prevline.linnum;
            addrdelta = lineptr->_386.off - prevline.off;
        } else {
            linedelta = (signed_32)lineptr->_286.linnum - prevline.linnum;
            addrdelta = lineptr->_286.off - prevline.off;
        }
        prevline.linnum += linedelta;
        prevline.off += addrdelta;
        dwsize += DWLineGen( linedelta, addrdelta, buff );
        lineptr = (void *)( (char *)lineptr + item_size );
    }
    CurrMod->d.d->dasi.size += dwsize;
}
Esempio n. 2
0
void DWENTRY DWLineNum(
    dw_client           cli,
    uint                info,
    dw_linenum          line_num,
    dw_column           column,
    dw_addr_offset      addr )
{
    uint_8              buf[ 3 + 2 * MAX_LEB128 ];
    uint_8              *end;
    unsigned            size;

    /* set the basic_block register properly */
    if( info & DW_LN_BLK ) {
        buf[ 0 ] = DW_LNS_set_basic_block;
        CLIWrite( DW_DEBUG_LINE, buf, 1 );
    }

    /* set the is_stmt register properly */
    if( info & DW_LN_STMT ) {
        if( !cli->debug_line.is_stmt ) {
            cli->debug_line.is_stmt = 1;
            buf[ 0 ] = DW_LNS_negate_stmt;
            CLIWrite( DW_DEBUG_LINE, buf, 1 );
        }
    } else if( cli->debug_line.is_stmt ) {
        cli->debug_line.is_stmt = 0;
        buf[ 0 ] = DW_LNS_negate_stmt;
        CLIWrite( DW_DEBUG_LINE, buf, 1 );
    }

    if( column != cli->debug_line.column ) {
        cli->debug_line.column = column;
        buf[ 0 ] = DW_LNS_set_column;
        end = LEB128( buf + 1, column );
        CLIWrite( DW_DEBUG_LINE, buf, end - buf );
    }

    size = DWLineGen( line_num - cli->debug_line.line,
                      addr - cli->debug_line.addr, buf );
    CLIWrite( DW_DEBUG_LINE, buf, size );
    cli->debug_line.addr = addr;
    cli->debug_line.line = line_num;
}
Esempio n. 3
0
void DwarfGenLines( lineinfo *info )
/**********************************/
{
    ln_off_pair _WCUNALIGNED *lineptr;
    unsigned            dwsize;
    dw_linenum_delta    linedelta;
    dw_addr_delta       addrdelta;
    virt_mem            vmem_addr;
    ln_off_386          prevline;
    offset              off;
    unsigned_8          buff[ 3 + 2 * MAX_LEB128 ];
    unsigned            size;
    segdata             *seg;
    unsigned            item_size;

    if( CurrMod->modinfo & MOD_DBI_SEEN )
        return;

    seg = info->seg;
    prevline.off = 0;
    prevline.linnum = 1;
    vmem_addr = CurrMod->d.d->dasi.u.vm_ptr;
    if( FmtData.type & MK_16BIT ) {
        dwsize = 3;
    } else {
        dwsize = 5;
    }
    buff[0] = 0;        // extended opcode
    buff[1] = dwsize;
    buff[2] = DW_LNE_set_address;
    if( FmtData.type & MK_16BIT ) {
        *( (unsigned_16 *)&buff[3] ) = seg->a.delta + seg->u.leader->seg_addr.off;
    } else {
        off = seg->a.delta + seg->u.leader->seg_addr.off;
        if( FmtData.type & (MK_PE | MK_QNX_FLAT | MK_ELF) ) {
            off += GetLinearGroupOffset( seg->u.leader->group );
        }
        *( (unsigned_32 *)&buff[3] ) = off;
    }
    dwsize += 2;
    PutInfo( vmem_addr, buff, dwsize );
    vmem_addr += dwsize;
    if( FmtData.type & MK_SEGMENTED ) {
        buff[1] = 3;
        buff[2] = DW_LNE_WATCOM_set_segment_OLD;
//        buff[2] = DW_LNE_WATCOM_set_segment;
        *( (unsigned_16 *)&buff[3] ) = seg->u.leader->seg_addr.seg;
        PutInfo( vmem_addr, buff, 5 );
        vmem_addr += 5;
    }
    if( info->size & LINE_IS_32BIT ) {
        item_size = sizeof( ln_off_386 );
    } else {
        item_size = sizeof( ln_off_286 );
    }
    lineptr = (ln_off_pair *)info->data;
    for( size = info->size & ~LINE_IS_32BIT; size > 0; size -= item_size ) {
        if( info->size & LINE_IS_32BIT ) {
            linedelta = (signed_32) lineptr->_386.linnum - prevline.linnum;
            addrdelta = lineptr->_386.off - prevline.off;
        } else {
            linedelta = (signed_32) lineptr->_286.linnum - prevline.linnum;
            addrdelta = lineptr->_286.off - prevline.off;
        }
        prevline.linnum += linedelta;
        prevline.off += addrdelta;
        dwsize = DWLineGen( linedelta, addrdelta, buff );
        PutInfo( vmem_addr, buff, dwsize );
        vmem_addr += dwsize;
        lineptr = (void *)( (char *)lineptr + item_size );
    }
    buff[0] = 0;        // extended opcode
    buff[1] = 1;        // size 1
    buff[2] = DW_LNE_end_sequence;
    PutInfo( vmem_addr, buff, 3 );
    CurrMod->d.d->dasi.u.vm_ptr = vmem_addr + 3;
}