Dtrace为内存溢出? [英] Dtrace for memory overflow?
问题描述
我想写一个Dtrace,以便我可以分析 overflow_error
是否正在执行的进程
中发生。我只是知道这是一个错误抛出 std :: overflow_error
。我不知道如何写一个D迹。我需要一些初学者指南,如果有人可以让我知道如何写它。我正在运行的进程名是 superbug_returns
。我如何写一个D-Trace分析如果上述情况发生或不是?我正在研究solaris
I want to write a Dtrace so that i can analyse if overflow_error
is happening in a process
i am executing . I just know that this is an error thrown as std::overflow_error
. I don't have much idea about how to write a D-Trace . I need some beginner guide and if someone can let me know how to write it . The process name i am running is say superbug_returns
. How can i write a D-Trace for it analyzing if above scenario is happening or not? I am working on solaris
推荐答案
我第二个建议尝试调试器与此 - 通常有一个命令, C ++ - 异常。
I second the suggestion to try the debugger with this - there's usually a command to break-on-C++-exception. It's simpler to go that way.
如果你坚持使用DTrace:
几年前,Sun发布了白皮书如何使用DTrace与C ++ - 阅读。
If you insist on DTrace:
A few years ago, Sun published a whitepaper how to use DTrace with C++ - read that.
将这里描述的技术应用到跟踪异常用例程序是不平凡的,不幸的是,因为异常抛出/处理是在C ++运行时,并通过内部(非曝光)函数调用。在gcc编译的代码中, throw ...
变成 __ cxa_throw(...)
,而在SunStudio编译的代码使用不同的名称管理方案)一个函数(unmangled / mangled):
It's not trivial to apply the techniques described there to the "trace exceptions" usecase, unfortunately, because exception throwing/handling is in the C++ runtime and done through internal (nonexposed) function calls. In gcc-compiled code, throw ...
becomes __cxa_throw(...)
whereas in SunStudio-compiled code (which uses a different name mangling scheme) a function (unmangled / mangled):
void __Crun::ex_throw(void*,const __Crun::static_type_info*,void(*)(void*))
__1cG__CrunIex_throw6Fpvpkn0AQstatic_type_info_pF1_v_v_
被调用。注意这取决于你的编译器版本; SunStudio在过去的某个时候改变了他们的修改方案/ C ++运行时。在这两种情况下, std :: ...
将作为参数传递,所以你想要DTrace为一个特定的异常类只有你需要二次过滤(一个D探测谓词,用于测试抛出的异常是否是您感兴趣的异常)。你需要找出上面的函数的参数对应于 std :: overflow
被抛出和过滤。
不你的实际目标文件,我不能给更多的建议。首先,请尝试:
is called. Note that this depends on your compiler version; SunStudio changed their mangling scheme / C++ runtime at some point in the past. In both cases though, std::...
would be passed as argument, so it you'd want to DTrace for a specific exception class only you'd need secondary filtering (a D probe predicate that tests whether the exception thrown is really the one you're interested in). You'd need to find out what args to the above function[s] correspond to std::overflow
being thrown and filter for those.
Without your actual object file, I can't give more advice than that. For a start, try:
gcc:
dtrace -n '
pid<your-process-pid>::__cxa_throw:entry
{
@exloc[ustack()] = count();
}'
SunStudio:
SunStudio:
dtrace -n '
pid<your-process-pid>::__1cG__CrunIex_throw6Fpvpkn0AQstatic_type_info_pF1_v_v_:entry
{
@exloc[ustack()] = count();
}'
在代码中查找抛出异常的位置(Ctrl + C终止DTrace给你的统计)。然后从那里进行迭代(尝试转储参数,看看是否可以标识 std :: overflow
,通过添加一个 / arg0 == ... /
或类似于探针)。
to find places in your code where exceptions are being thrown (Ctrl+C to terminate the DTrace gives you the statistics). Then iterate from there (try to dump the args, see if you can identify std::overflow
, filter for that by adding a /arg0 == .../
or similar to the probe).
这篇关于Dtrace为内存溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!