fn evaluate_exprloc(
    expression: gimli::Expression<EndianSlice<RunTimeEndian>>,
    encoding: gimli::Encoding
) -> Option<u64> {
    let mut evaluation = expression.evaluation(encoding);
    evaluation.set_object_address(0);
    evaluation.set_initial_value(0);
    evaluation.set_max_iterations(100);
    let mut eval_result = evaluation.evaluate().unwrap();
    while eval_result != gimli::EvaluationResult::Complete {
        match eval_result {
            gimli::EvaluationResult::RequiresRelocatedAddress(address) => {
                // assume that there is no relocation
                // this would be a bad bet on PC, but on embedded controllers where A2l files are used this is the standard
                eval_result = evaluation.resume_with_relocated_address(address).unwrap();
            },
            gimli::EvaluationResult::RequiresFrameBase => {
                // a variable in the stack frame of a function. Not useful in the conext of A2l files, where we only care about global values
                return None;
            }
            gimli::EvaluationResult::RequiresRegister { .. } => {
                // the value is relative to a register (e.g. the stack base)
                // this means it cannot be referenced at a unique global address and is not suitable for use in a2l
                return None;
            }
            other => {
                println!("evaluate_exprloc eval result is unhandled: {:#?}", other);
                return None;
            }
        };
    }
    let result = evaluation.result();
    if let gimli::Piece {location: gimli::Location::Address {address}, ..} = result[0] {
        Some(address)
    } else {
        None
    }
}
// evaluate an exprloc expression to get a variable address or struct member offset
evaluate an exprloc expression to get a variable address or struct member offset
evaluate an exprloc expression to get a variable address or struct member offset
fn evaluate_exprloc(
    expression: gimli::Expression<EndianSlice<RunTimeEndian>>,
    encoding: gimli::Encoding
) -> Option<u64> {
    let mut evaluation = expression.evaluation(encoding);
    evaluation.set_object_address(0);
    evaluation.set_initial_value(0);
    evaluation.set_max_iterations(100);
    let mut eval_result = evaluation.evaluate().unwrap();
    while eval_result != gimli::EvaluationResult::Complete {
        match eval_result {
            gimli::EvaluationResult::RequiresRelocatedAddress(address) => {
                // assume that there is no relocation
                // this would be a bad bet on PC, but on embedded controllers where A2l files are used this is the standard
                eval_result = evaluation.resume_with_relocated_address(address).unwrap();
            },
            gimli::EvaluationResult::RequiresFrameBase => {
                // a variable in the stack frame of a function. Not useful in the conext of A2l files, where we only care about global values
                return None;
            }
            gimli::EvaluationResult::RequiresRegister { .. } => {
                // the value is relative to a register (e.g. the stack base)
                // this means it cannot be referenced at a unique global address and is not suitable for use in a2l
                return None;
            }
            other => {
                println!("evaluate_exprloc eval result is unhandled: {:#?}", other);
                return None;
            }
        };
    }
    let result = evaluation.result();
    if let gimli::Piece {location: gimli::Location::Address {address}, ..} = result[0] {
        Some(address)
    } else {
        None
    }
}
fn evaluate_exprloc ( expression : gimli :: Expression < EndianSlice < RunTimeEndian > > , encoding : gimli :: Encoding ) -> Option < u64 > { let mut evaluation = expression . evaluation ( encoding ) ; evaluation . set_object_address ( 0 ) ; evaluation . set_initial_value ( 0 ) ; evaluation . set_max_iterations ( 100 ) ; let mut eval_result = evaluation . evaluate ( ) . unwrap ( ) ; while eval_result != gimli :: EvaluationResult :: Complete { match eval_result { gimli :: EvaluationResult :: RequiresRelocatedAddress ( address ) => { // assume that there is no relocation // this would be a bad bet on PC, but on embedded controllers where A2l files are used this is the standard eval_result = evaluation . resume_with_relocated_address ( address ) . unwrap ( ) ; } , gimli :: EvaluationResult :: RequiresFrameBase => { // a variable in the stack frame of a function. Not useful in the conext of A2l files, where we only care about global values return None ; } gimli :: EvaluationResult :: RequiresRegister { .. } => { // the value is relative to a register (e.g. the stack base) // this means it cannot be referenced at a unique global address and is not suitable for use in a2l return None ; } other => { println ! ( " " other ) ; return None ; } } ; } let result = evaluation . result ( ) ; if let gimli :: Piece { location : gimli :: Location :: Address { address } , .. } = result [ 0 ] { Some ( address ) } else { None } }
evaluate an exprloc expression to get a variable address or struct member offset
evaluate an exprloc expression to get a variable address or struct member offset
expression
gimli::Expression<EndianSlice<RunTimeEndian>>
encoding
gimli::Encoding