如何细化调试? [英] How to refine the debugging?

查看:136
本文介绍了如何细化调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

崩溃报告(SASL)或多或少地提供了一个错误发生的原因。
但是可以细化这个(函数,行代码等)吗?

解决方案

如果你可以重现故障,获取更多信息的最佳方法是将dbg跟踪放在有问题的部分,并查看该输出。

  DBG:示踪剂(),DBG:p(所有,C),DBG:TPL器(Mod,Func键,X)。 

这通常对我来说是窍门。使用您想要调试的任何模块和功能替换Mod和Func。



如果您正在寻找更详细的验尸记录,那么sasl和error_logger是您的朋友。当然SASL没有给你足够的信息,如果这种情况发生在您的系统中,您可能应该更好地了解SASL输出或者编写自己的日志处理程序。将自己的错误处理程序插入到SASL中并将其输出到您想要的位置是非常容易的。



然而,您将不会收到行号,因为该信息在编译时被销毁时间,VM没有办法知道哪一行崩溃了。然而,它知道哪个功能,可能有哪些参数,因为通常可以找出事情出错的地方。除非你写得很长的功能,哪个IMO是不好的代码气味,还有一个标志,你应该把你的代码重构为更小的功能。


Crash report (SASL) gives more or less where and why a bug happens. But is it possible to refine this (the function, the line de code, etc) ?

解决方案

If you can reproduce the fault, the best way to get more information is to put a dbg trace on sections in question and review that output.

dbg:tracer(),dbg:p(all,c),dbg:tpl(Mod,Func,x).

This usually does the trick for me. Replace Mod and Func with whatever module and function you want to debug.

If you are looking for more detailed post-mortem logging then sasl and the error_logger are your friends. There are of course times when SASL does not give you enough info, if this happens a lot in your system you probably should either learn to understand the SASL output better or write your own log handler. It is quite easy to plug-in your own error handler into SASL and output things as you want.

You will however never get line number as that information is destroyed at compilation time and there is no way for the VM to know which line crashed. It does however know which function and possibly with which arguments, given this it is usually possible to find out where things went wrong. Unless you write very long functions, which IMO is bad code smell and a sign that you should refactor your code to smaller functions.

这篇关于如何细化调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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