是否可以让调试器显示 boost 函数对象指向的函数的名称?

发布于 2024-07-25 16:14:12 字数 590 浏览 2 评论 0原文

在 Visual Studio 中使用 boost 函数和绑定调试代码时,我希望能够让调试器显示有关 boost 函子指向的实际函数的信息。 例如函数的名称、原始函数的签名(在对其使用绑定之前)或函子的状态。

目前,我必须单步执行代码才能找出它是哪个函数,这需要首先单步执行 boost 代码。

有谁知道这是否已经完成或者是否可以完成?

谢谢你!

编辑我也很高兴发现现在有人已经找到了这个问题的答案:如何调试使用 boost 的代码而不失去理智?

(我的意思是 接受的答案:如何跳过boost代码,但是仍然单步执行 boost::function 调用的代码...)

When debugging code using boost function and bind in Visual Studio, I would like to be able to have the debugger show information about the actual function pointed to by the boost functor. For instance the name of the function, the signature of the original function (before bind was used on it), or the state of the functor.

At the moment I have to step through the code to find out which function it is, and that requires stepping all the way through the boost code first.

Does anyone know if this has been done or even if it can be done?

Thank you!

Edit I'd also be very happy to find out that someone has developed an answer to this question by now: How to debug code that uses boost w/o losing sanity?

(I mean the problem mentioned in the accepted answer: How to step over the boost code but still step into the code called by the boost::function...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

長街聽風 2024-08-01 16:14:12

boost 中有一项计划是要调试可视化工具。 已经有针对不同类型(variant、multi_index、shared_ptr 等)的调试可视化工具。

不幸的是 boost::function 不存在,但是您可以按照那里的描述自己编写一个可视化工具(也可以将其提交给 boost ;)。 或者,您可以请求为您写一份。

问候,
奥瓦内斯

There is an initiative in boost to make debug visualizers. There are already debug visualizers for different types (variant, multi_index, shared_ptr and more).

Unfortunately boost::function is not there, but you can write a visualizer yourself as described there (and maybe submit it to boost ;). Alternatively you can make a request to write one for you.

Regards,
Ovanes

挽梦忆笙歌 2024-08-01 16:14:12

使用 Visual Studio 及其调试可视化工具(如 ovanes 所指出的那样),将鼠标悬停在变量上时可以获取指向的函数。

由于我不想在这篇文章中充斥大量垃圾邮件,因此我在此仅提供前 12 个函数类型。 如果您确实需要更多,您可能可以扩展它。 我将类似的代码发送给了 boost doc 开发人员,最终它也将在那里发布。

目前,当没有任何内容实际绑定到函数对象时,此可视化工具类型将显示或多或少的垃圾。 请注意,这在某种程度上是一个早期草案。


boost::function0<*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function1<*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function2<*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function3<*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function4<*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function5<*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function6<*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function7<*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function8<*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function9<*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function10<*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function11<*,*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function12<*,*,*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }

Using visual studio and it's Debug Visualizer, as pointed to by ovanes, it is possible to get the pointed to function when hovering over the variable.

As I don't want to spam this post full of it, I only provide here the first 12 function types. If you really need more you will likely be able to extend it. I sent similar code to a boost doc developer and eventually it will get published there as well.

Currently, this visualizer type will display more or less garbage, when nothing is actually bound to an function object. And please note that this is somewhat an early draft.


boost::function0<*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function1<*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function2<*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function3<*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function4<*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function5<*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function6<*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function7<*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function8<*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function9<*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function10<*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function11<*,*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
boost::function12<*,*,*,*,*,*,*,*,*,*,*,*,*> { preview( #("func=", $e.functor.bound_memfunc_ptr.memfunc_ptr) ) }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文