为什么在X86上执行单步指令? [英] Why Single Stepping Instruction on X86?

查看:91
本文介绍了为什么在X86上执行单步指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,有一个 int 3,它是用于调试器中的断点的中断指令。

So there is "int 3" which is an interrupt instruction used for breakpoints in debuggers.

但是还有一个 int 1,它用于单个调试器。踩。但是为什么需要这个呢?我已经读到,在EFLAGS寄存器中设置陷阱标志(TF)将启用单步执行,并且会为每条指令捕获到OS中。那么为什么需要一个单独的中断类型呢?

But then there is also "int 1" which is used for single stepping. But why is this needed? I've read that setting the Trap Flag (TF) in EFLAGS register will enable single stepping and will trap into the OS for each instruction. So why is a separate interrupt type needed?

谢谢!

推荐答案

int 3 是一个特殊的1字节中断。如果存在,调用它将进入调试器,否则应用程序通常会崩溃。

int 3 is a special 1-byte interrupt. Invoking it will break into the debugger if one is present, otherwise the application will typically crash.

当调试器设置陷阱标志时,这将导致处理器自动执行每条指令后 int 1 中断。这使调试器可以单步执行指令,而不必插入 int 3 指令。您不必显式调用此中断。

When the debugger sets the trap flag, this causes the processor to automatically execute an int 1 interrupt after every instruction. This allows the debugger to single-step by instructions, without having to insert an int 3 instruction. You do not have to invoke this interrupt explicitly.

这篇关于为什么在X86上执行单步指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆