Ejemplo n.º 1
0
extern char *DRGetFileName( drmem_hdl entry )
/*******************************************/
{
    drmem_hdl           abbrev;
    char *              name;
    dr_fileidx          fileidx;

    name = NULL;
    abbrev = DWRSkipTag( &entry ) + 1;
    if( DWRScanForAttrib( &abbrev, &entry, DW_AT_decl_file ) ) {
        fileidx = (dr_fileidx)DWRReadConstant( abbrev, entry );
        name = DWRFindFileName( fileidx, entry );
    }
    return( name );
}
Ejemplo n.º 2
0
static void References( ReferWhich which, dr_handle entry, void *data1,
                hook_func do_callback, void *data2, DRSYMREF callback )
/*********************************************************************/
{
    dr_handle   loc;
    dr_handle   end;
    dr_handle   owning_node;
    dr_handle   infoOffset;
    unsigned_8  opcode;
    dr_ref_info registers = { { 0, 0, NULL }, 0L, NULL, 1L, 1 };
    bool        quit = FALSE;
    bool        inScope = FALSE;

    loc = DWRCurrNode->sections[ DR_DEBUG_REF ].base;
    end = loc + DWRCurrNode->sections[ DR_DEBUG_REF ].size;
    infoOffset = DWRCurrNode->sections[ DR_DEBUG_INFO ].base;

    loc += sizeof( unsigned_32 );   /* skip size */
    while( loc < end && !quit ) {
        opcode = DWRVMReadByte( loc );
        loc += sizeof( unsigned_8 );

        switch( opcode ) {
        case REF_BEGIN_SCOPE:
            owning_node = DWRVMReadDWord( loc ) + infoOffset;
            loc += sizeof( unsigned_32 );
            ScopePush( &registers.scope, owning_node );
            if( (which & REFERSTO) != 0 && owning_node == entry ) {
                inScope = TRUE;
            }
            break;

        case REF_END_SCOPE:
            ScopePop( &registers.scope );
            inScope = FALSE;
            break;

        case REF_SET_FILE:
            registers.file = DWRFindFileName( DWRVMReadULEB128( &loc ), infoOffset );
            break;

        case REF_SET_LINE:
            registers.line = DWRVMReadULEB128( &loc );
            break;

        case REF_SET_COLUMN:
            registers.column = (unsigned_8)DWRVMReadULEB128( &loc );
            break;

        case REF_ADD_LINE:
            registers.line += DWRVMReadSLEB128( &loc );
            registers.column = 0;
            break;

        case REF_ADD_COLUMN:
            registers.column += (signed_8)DWRVMReadSLEB128( &loc );
            break;

        case REF_COPY:
        default:
            if( opcode >= REF_CODE_BASE ) {
                unsigned_32 ld;

                opcode -= REF_CODE_BASE;

                ld = opcode / REF_COLUMN_RANGE;
                if( ld != 0 ) {
                    registers.column = 0;
                    registers.line += ld;
                }
                registers.column += opcode % REF_COLUMN_RANGE;

                registers.dependent = DWRVMReadDWord( loc ) + infoOffset;
                loc += sizeof( unsigned_32 );
            }

            quit = FALSE; /* don't terminate */
            if( do_callback( &registers, data1 ) || inScope ) {
                char    *name = NULL;

                owning_node = ScopeLastNameable( &registers.scope, &name );

                /* make sure that there is something nameable on the stack */
                if( owning_node != DR_HANDLE_NUL ) {
                    quit = !callback( owning_node, &registers, name, data2 );
                }
            }
            break;
        }
    }

    DWRFREE( registers.scope.stack );
}