简体   繁体   English

实时与离线调试

[英]Live vs. offline debugging

I've been trying to find the difference between these 2 types of debugging, but couldn't find it anywhere (been googling almost 30 minutes), so I'm asking here: What's the difference between live vs. offline debugging? 我一直在尝试找到这两种调试类型之间的区别,但是找不到任何地方(谷歌搜索了将近30分钟),所以我在这里问:实时调试与离线调试之间有什么区别? What do people mean when they say a debugger is "live" vs. "offline"? 人们说调试器“在线”与“离线”是什么意思?

"Online" debugging is the normal process: “在线”调试是正常过程:

  • Tell the debugger to tell the program to step forwards; 告诉调试器告诉程序前进;
  • Look at what the program state is at the moment; 看一下当前程序状态。
  • Set a breakpoint for the future; 为未来设定断点;
  • Tell the debugger to simply run the program; 告诉调试器只运行程序;
  • If the breakpoint 'fires', have a look at the program state now. 如果断点“触发”,请立即查看程序状态。

There are two ways to "offline" debug: 有两种“离线”调试方法:

  1. You can take your source code and manually step through what the processor ought to be doing, watching for unexpected program paths. 您可以获取源代码,并手动逐步处理处理器应该做什么,观察意外的程序路径。

    Note if you do this, you need to diligently not "know" what the processor is "supposed" to do and just do that: you need to honestly obey the code as though you were the computer. 请注意,如果执行此操作,则无需勤奋地“知道”处理器要“做什么”,而要这样做:您必须诚实地遵守代码,就像是计算机一样。 Often you get other people, who don't know the code, to do this instead of you. 通常,您会得到不知道代码的其他人来代替您执行此操作。

  2. You take the result of a run-log, usually captured by a hardware probe, and use the debugger to "post mortem" the run. 您获取运行日志的结果(通常是由硬件探测器捕获),然后使用调试器对运行进行“事后检验”。

The latter usually requires a processor that will transmit what it is doing out a "Trace" port (not all have this), and a hardware device (like a probe) connected to the Trace port to capture the data. 后者通常需要一个处理器,该处理器将通过“跟踪”端口(不是所有人都具有此端口)传输正在执行的操作,以及连接到跟踪端口以捕获数据的硬件设备(例如探针)。 That probe then communicates with a debugger, which takes the data and presents it to the programmer. 然后,该探针与调试器进行通信,调试器获取数据并将其提供给程序员。 The programmer can work backwards and forwards through this Trace log, and see the execution path that the code actually took, rather than the code the programmer thought it should take. 程序员可以在此跟踪日志中来回工作,并查看代码实际采用的执行路径,而不是程序员认为应该采用的代码。

Some processors not only transmit what instruction they're currently processing, but also what data they read or wrote while doing this. 一些处理器不仅传输他们当前正在处理的指令,而且传输他们在执行此操作时读取或写入的数据。 A more sophisticated debugger can take this extra data and provide a 'snapshot' of the system at any time during the run, allowing the programmer to analyse why the code behaved the way it did. 一个更复杂的调试器可以获取这些额外的数据,并在运行期间的任何时间提供系统的“快照”,从而使程序员能够分析代码为何以这种方式运行。

The reason that it is called "offline" is because once the log has been captured, you can disconnect and power down the target, and look at the saved log at any time in the future without still being connected to the probe or processor. 之所以称其为“离线”,是因为一旦捕获了日志,您就可以断开连接并关闭目标电源,并在将来的任何时候查看保存的日志,而无需仍然连接到探针或处理器。

Debugging types 调试类型

There are several ways of debugging that can be distinguished: 可以区分几种调试方式:

  1. live debugging vs. post mortem debugging (what you call "offline" debugging, also called "dump debugging") 实时调试与事后调试(您称为“离线”调试,也称为“转储调试”)
  2. kernel debugging vs. user mode debugging 内核调试与用户模式调试
  3. local debugging vs. remote debugging 本地调试与远程调试

which give 8 combinations in total. 共提供8种组合。

For live debugging, you can distinguish between invasive debugging vs. noninvasive debugging. 对于实时调试,您可以区分侵入式调试与非侵入式调试。

Live debugging vs. offline debugging 实时调试与离线调试

In live debugging, the program is running and the debugger is attached to it. 在实时调试中,程序正在运行,并且调试器已连接到该程序。 This means you can still interact with the program. 这意味着您仍然可以与该程序进行交互。 You can set breakpoints, handle exceptions that would normally cause the program to terminate, modify the memory etc. 您可以设置断点,处理通常会导致程序终止的异常,修改内存等。

The downside of live debugging is its temporal/fluent nature. 实时调试的缺点是其时间/流利性。 If you enter a wrong command or step too far, the situation is gone and might not be repeatable. 如果您输入了错误的命令或步骤太远,则情况将消失,并且可能无法重复。

I mentioned that there are 2 sub-modes for live debugging: invasive and noninvasive debugging: in noninvasive debugging, the debugger does not attach to the target application. 我提到有两种用于实时调试的子模式:侵入式和非侵入式调试:在非侵入式调试中,调试器未附加到目标应用程序。 It suspends all of the program's threads and has access to the memory, registers, and other such information. 它挂起了程序的所有线程,并可以访问内存,寄存器和其他此类信息。 However, the debugger cannot control the target. 但是,调试器无法控制目标。

In post mortem debugging, someone has captured a memory dump of a running program at a certain point in time. 在事后调试中,有人在某个时间点捕获了正在运行的程序的内存转储。 In many cases this is done upon a specific event, eg an unhandled exception that causes the program to terminate. 在许多情况下,这是根据特定事件完成的,例如,导致程序终止的未处理异常。 Since the memory dump is a file on disk, you can analyze it as often as you want and you get the exact same situation. 由于内存转储是磁盘上的一个文件,因此您可以根据需要进行多次分析,并且情况完全相同。

The downside if post mortem debugging is, of course, that the program is not running, you can't interact with it and it's very hard to find out what happens next. 当然,事后调试的不利之处在于该程序未运行,您无法与它进行交互,因此很难确定下一步将发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM