src/developer/debug/zxdb/symbols/dwarf_expr_eval.cc
// 1 paramter: ULEB size of item in bytes.
1 paramter: ULEB size of item in bytes.
1 paramter : ULEB size of item in bytes .
DwarfExprEval::Completion DwarfExprEval::OpPiece() {
  StackEntry byte_size = 0;
  if (!ReadLEBUnsigned(&byte_size))
    return Completion::kSync;
  if (stack_.empty()) {
    ReportStackUnderflow();
    return Completion::kSync;
  }
  StackEntry source = stack_.back();
  stack_.pop_back();
  if (result_type_ == ResultType::kValue) {
    if (byte_size > sizeof(StackEntry)) {
      ReportError(fxl::StringPrintf("DWARF expression listed a data size of %d which is too large.",
                                    static_cast<int>(byte_size)));
      return Completion::kSync;
    }
    uint8_t source_as_bytes[sizeof(StackEntry)];
    memcpy(&source_as_bytes, &source, sizeof(StackEntry));
    result_data_.insert(result_data_.end(), std::begin(source_as_bytes),
                        &source_as_bytes[byte_size]);
    result_type_ = ResultType::kPointer;
    return Completion::kSync;
  }
  ReadMemory(source, byte_size, [](DwarfExprEval* eval, std::vector<uint8_t> data) {
    eval->result_data_.insert(eval->result_data_.end(), data.begin(), data.end());
    eval->result_type_ = ResultType::kPointer;
  });
  return Completion::kAsync;
}
DwarfExprEval :: Completion DwarfExprEval :: OpPiece ( ) { StackEntry byte_size = 0 ; if ( ! ReadLEBUnsigned ( & byte_size ) ) return Completion :: kSync ; if ( stack_ . empty ( ) ) { ReportStackUnderflow ( ) ; return Completion :: kSync ; } StackEntry source = stack_ . back ( ) ; stack_ . pop_back ( ) ; if ( result_type_ == ResultType :: kValue ) { if ( byte_size > sizeof ( StackEntry ) ) { ReportError ( fxl :: StringPrintf ( " " , static_cast < int > ( byte_size ) ) ) ; return Completion :: kSync ; } uint8_t source_as_bytes [ sizeof ( StackEntry ) ] ; memcpy ( & source_as_bytes , & source , sizeof ( StackEntry ) ) ; result_data_ . insert ( result_data_ . end ( ) , std :: begin ( source_as_bytes ) , & source_as_bytes [ byte_size ] ) ; result_type_ = ResultType :: kPointer ; return Completion :: kSync ; } ReadMemory ( source , byte_size , [ ] ( DwarfExprEval * eval , std :: vector < uint8_t > data ) { eval -> result_data_ . insert ( eval -> result_data_ . end ( ) , data . begin ( ) , data . end ( ) ) ; eval -> result_type_ = ResultType :: kPointer ; } ) ; return Completion :: kAsync ; }
1 paramter: ULEB size of item in bytes.
1 paramter : ULEB size of item in bytes .
// Simple case where the source of the "piece" is the value at the top of the stack. // We want the low bytes, this assumes little-endian. // Reset the expression state to start a new one. // This is the more complex case where the top of the stack is a pointer to the value in memory. // We read that many bytes from memory and add it to the result data. // Success. Copy to the result. // Reset the expression state to start a new one. // The ReadMemory call will complete asynchronously.