Repository: aptos-labs/aptos-core
File: third_party/move/move-vm/runtime/src/interpreter.rs (Rust)

Code before:
                            )?;
                            eprintln!(
                                "trace abort_msg({}, {}): {}",
                                error_code, error_message, str
                            );
                        }
                        let error = PartialVMError::new(StatusCode::ABORTED)
                            .with_sub_status(error_code)
                            .with_message(error_message);

                        // Before returning an abort error, ensure the instruction is recorded in
                        // the trace, so the trace is full.
                        trace_recorder.record_successful_instruction(instruction);
                        return Err(error);
                    },
                    Instruction::Eq => {
                        let lhs = interpreter.operand_stack.pop()?;
                        let rhs = interpreter.operand_stack.pop()?;
                        gas_meter.charge_eq(&lhs, &rhs)?;
                        interpreter
                            .operand_stack
                            .push(Value::bool(lhs.equals(&rhs)?))?;
                    },
                    Instruction::Neq => {
                        let lhs = interpreter.operand_stack.pop()?;
                        let rhs = interpreter.operand_stack.pop()?;
                        gas_meter.charge_neq(&lhs, &rhs)?;
                        interpreter
                            .operand_stack
                            .push(Value::bool(!lhs.equals(&rhs)?))?;
                    },
                    Instruction::MutBorrowGlobal(sd_idx) | Instruction::ImmBorrowGlobal(sd_idx) => {
                        let is_mut = matches!(instruction, Instruction::MutBorrowGlobal(_));
                        let addr = interpreter.operand_stack.pop_as::<AccountAddress>()?;
                        let ty = self.get_struct_ty(*sd_idx);
                        interpreter.borrow_global(
                            is_mut,
                            false,
                            data_cache,
                            gas_meter,
                            traversal_context,
                            addr,
                            &ty,
                        )?;
                    },
                    Instruction::MutBorrowGlobalGeneric(si_idx)
                    | Instruction::ImmBorrowGlobalGeneric(si_idx) => {
                        let is_mut = matches!(instruction, Instruction::MutBorrowGlobalGeneric(_));
                        let addr = interpreter.operand_stack.pop_as::<AccountAddress>()?;
                        let (ty, ty_count) = frame_cache.get_struct_type(*si_idx, self)?;
                        gas_meter.charge_create_ty(ty_count)?;

Review comment (suggestion):
You should add a new parameter for new instruction (gas profiler uses instruction `S` opcodes to log some info

Code after:
                    },
                    Instruction::Abort => {
                        gas_meter.charge_simple_instr(S::Abort)?;
                        let error_code = interpreter.operand_stack.pop_as::<u64>()?;
                        if is_tracing_for!(TraceCategory::Abort(error_code)) {
                            let mut str = String::new();
                            interpreter.debug_print_stack_trace(
                                &mut str,
                                interpreter.loader.runtime_environment(),
                            )?;
                            eprintln!("trace abort({}): {}", error_code, str);
                        }

                        // Important: do not attach a message here.
                        // We rely on the presence of an error message to distinguish
                        // aborts with explicit messages (see below) from those without.
                        let error =
                            PartialVMError::new(StatusCode::ABORTED).with_sub_status(error_code);

                        // Before returning an abort error, ensure the instruction is recorded in
                        // the trace, so the trace is full.
                        trace_recorder.record_successful_instruction(instruction);
                        return Err(error);
                    },
                    Instruction::AbortMsg => {
                        gas_meter.charge_simple_instr(S::Abort)?;

                        let vec = interpreter.operand_stack.pop_as::<Vector>()?;
                        let bytes = vec.to_vec_u8()?;
                        // TODO(aborts): Add a test that triggers this error.
                        let error_message = String::from_utf8(bytes).map_err(|err| {
                            PartialVMError::new(StatusCode::INVALID_ABORT_MESSAGE)
                                .with_message(format!("Invalid UTF-8 string: {err}"))
                        })?;

                        let error_code = interpreter.operand_stack.pop_as::<u64>()?;

                        if is_tracing_for!(TraceCategory::Abort(error_code)) {
                            let mut str = String::new();
                            interpreter.debug_print_stack_trace(
                                &mut str,
                                interpreter.loader.runtime_environment(),
                            )?;
                            eprintln!(
                                "trace abort_msg({}, {}): {}",
                                error_code, error_message, str
                            );
                        }
                        let error = PartialVMError::new(StatusCode::ABORTED)
                            .with_sub_status(error_code)
                            .with_message(error_message);