gpt4 book ai didi

c - 如何模拟 gdb 中的减速?

转载 作者:太空宇宙 更新时间:2023-11-04 00:37:43 25 4
gpt4 key购买 nike

我有一个并发程序,当我正常运行它时,一切正常。但是,在使用 valgrind 时,我遇到了(可能是死锁)问题,很可能是因为 valgrind 导致程序运行速度变慢。我尝试使用 gdb 调试程序,但我还是无法重现错误。我想知道是否有某种方法可以让 gdb 运行得更慢,这样我就可以重现并找到错误。该程序在远程服务器上运行。

程序非常庞大,并发负载很高,因此纯代码分析在这一点上不太现实。

最佳答案

when using valgrind, I run into (probably deadlock) issues,

当您在 valgrind 下运行您的程序时,有一种方法可以分析您的问题。使用 valgrind 中的 gdbserver 特性来分析这个死锁。在 valgrind 下运行您的程序,遇到死锁,然后附加 gdb 并调查您的死锁。这是来自 valgrind 文档:

A program running under Valgrind is not executed directly by the CPU. Instead it runs on a synthetic CPU provided by Valgrind. This is why a debugger cannot debug your program when it runs on Valgrind.

This section describes how GDB can interact with the Valgrind gdbserver to provide a fully debuggable program under Valgrind.

所以你需要这样在valgrind下运行你的程序:

valgrind --vgdb=yes --vgdb-error=0 prog

一旦遇到死锁,请根据此处的说明在 gdb 下附加到死锁:http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver .

我认为如果你确实遇到了死锁,那么你需要在 gdb 中运行 thread apply all backtrace

关于c - 如何模拟 gdb 中的减速?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23785033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com