simpleperf/report_html.js
// Return a list of disassembly related to a function.
Return a list of disassembly related to a function.
Return a list of disassembly related to a function .
function collectDisassemblyForFunction(func) {
    if (!func.hasOwnProperty('a')) {
        return null;
    }
    let hitAddrs = func.a;
    let rawCode = getFuncDisassembly(func.f);
    if (!rawCode) {
        return null;
    }
    let annotatedCode = [];
    let codeForLastAddr = null;
    let hitAddrPos = 0;
    let hasCount = false;
    function addEventCount(addr) {
        while (hitAddrPos < hitAddrs.length && BigInt(hitAddrs[hitAddrPos].a) < addr) {
            if (codeForLastAddr) {
                codeForLastAddr.eventCount += hitAddrs[hitAddrPos].e;
                codeForLastAddr.subtreeEventCount += hitAddrs[hitAddrPos].s;
                hasCount = true;
            }
            hitAddrPos++;
        }
    }
    for (let line of rawCode) {
        let code = line[0];
        let addr = BigInt(line[1]);
        addEventCount(addr);
        let item = {code: code, eventCount: 0, subtreeEventCount: 0};
        annotatedCode.push(item);
        if (addr != 0) {
            codeForLastAddr = item;
        }
    }
    addEventCount(Number.MAX_VALUE);
    return hasCount ? annotatedCode : null;
}
function collectDisassemblyForFunction ( func ) { if ( ! func . hasOwnProperty ( 'a' ) ) { return null ; } let hitAddrs = func . a ; let rawCode = getFuncDisassembly ( func . f ) ; if ( ! rawCode ) { return null ; } let annotatedCode = [ ] ; let codeForLastAddr = null ; let hitAddrPos = 0 ; let hasCount = false ; function addEventCount ( addr ) { while ( hitAddrPos < hitAddrs . length && BigInt ( hitAddrs [ hitAddrPos ] . a ) < addr ) { if ( codeForLastAddr ) { codeForLastAddr . eventCount += hitAddrs [ hitAddrPos ] . e ; codeForLastAddr . subtreeEventCount += hitAddrs [ hitAddrPos ] . s ; hasCount = true ; } hitAddrPos ++ ; } } for ( let line of rawCode ) { let code = line [ 0 ] ; let addr = BigInt ( line [ 1 ] ) ; addEventCount ( addr ) ; let item = { code : code , eventCount : 0 , subtreeEventCount : 0 } ; annotatedCode . push ( item ) ; if ( addr != 0 ) { codeForLastAddr = item ; } } addEventCount ( Number . MAX_VALUE ) ; return hasCount ? annotatedCode : null ; }
Return a list of disassembly related to a function.
Return a list of disassembly related to a function .
// Annotate disassembly with event count information. // Objdump sets addr to 0 when a disassembly line is not associated with an addr.