分析多线程序 [英] Analyzing Multithreaded Programs

查看:132
本文介绍了分析多线程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个几年的代码库,所有的原始开发人员都已经走了。它使用许多,许多线程,但没有明显的设计或常见的架构原则。每个开发人员都有自己的风格的多线程编程,所以一些线程使用队列,一些锁数据互斥,一些锁信号量,一些使用操作系统IPC机制进行内部进程通信相互通信。没有设计文档,评论很稀疏。这是一个麻烦,似乎只要我们尝试重构代码或添加新的功能,我们引入死锁或其他问题。

We have a codebase that is several years old, and all the original developers are long gone. It uses many, many threads, but with no apparent design or common architectural principles. Every developer had his own style of multithreaded programming, so some threads communicate with one another using queues, some lock data with mutexes, some lock with semaphores, some use operating-system IPC mechanisms for intra-process communications. There is no design documentation, and comments are sparse. It's a mess, and it seems that whenever we try to refactor the code or add new functionality, we introduce deadlocks or other problems.

所以,有没有人知道任何工具或技术,将有助于分析和记录线程之间的所有交互? FWIW,代码库在Linux上是C ++,但我很想知道其他环境的工具。

So, does anyone know of any tools or techniques that would help to analyze and document all the interactions between threads? FWIW, the codebase is C++ on Linux, but I'd be interested to hear about tools for other environments.

我欣赏到目前为止收到的回复,但我希望有一些更复杂或系统性的建议,本质上是添加日志消息,弄清楚发生了什么,修理它。有很多工具用于分析和记录单线程程序中的控制流;多线程程序没有什么可用的?

I appreciate the responses received so far, but I was hoping for something more sophisticated or systematic than advice that is essentially "add log messages, figure out what's going on, and fix it." There are lots of tools out there for analyzing and documenting control-flow in single-threaded programs; is there nothing available for multi-threaded programs?

另请参见调试多线程应用程序

推荐答案

VTune 及其线程概要分析工具。它将为您提供线程行为的系统和源级视图。它肯定不会为你自动记录的东西,但应该是一个真正的帮助,至少可视化在不同情况下发生了什么。

Invest in a copy of Intel's VTune and its thread profiling tools. It will give you both a system and a source level view of the thread behaviour. It's certainly not going to autodocument the thing for you, but should be a real help in at least visualising what is happening in different circumstances.

我想有一个试用版你可以下载,所以可能值得给一个去。我只使用Windows版本,但看着VTune网页,它也有一个Linux版本。

I think there is a trial version that you can download, so may be worth giving that a go. I've only used the Windows version, but looking at the VTune webpage it also has a Linux version.

这篇关于分析多线程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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