gdb:循环执行期间如何暂停? [英] gdb: How do I pause during loop execution?

查看:155
本文介绍了gdb:循环执行期间如何暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 7中使用NetBeans 7作为我的IDE,在g ++中编写一个软件渲染器,使用NetBeans 7。



我一直需要对其进行配置这个需求已经到了临界,现在我已经放弃了结构。我环顾四周,和我一起这个答案显示了同时跨平台并保持简单的最大的希望。



该方法的要点是可能是最基本的(并且在许多方法,最准确)的方式来简要/优化是简单地直接对堆栈进行抽样,然后通过暂停执行...不幸的是,NetBeans 不会暂停。所以我试图找出如何使用gdb直接进行抽样。



我不太了解gdb。我可以从手册页可以看出,你在运行你的可执行文件之前先设置了断点。有没有人帮助我。



有谁知道一个简单的方法来获取gdb(或其他gnu工具):


  1. 当我这样说(优选)

  2. 以随机间隔抽取一堆样本

...给我陈述的配置?

您是否尝试过在gdb中运行可执行文件,然后在打断中断的时候只要打到^ C( Ctrl + C )?那应该把你放到gdb的提示符下,在那里你可以简单地运行命令来查看你在哪里,然后继续执行 continue

如果您发现自己处于无关的线程(例如循环UI线程),请使用线程信息线程线程n 转到正确的一个,然后执行 where


I'm writing a software renderer in g++ under mingw32 in Windows 7, using NetBeans 7 as my IDE.

I've been needing to profile it of late, and this need has reached critical mass now that I'm past laying down the structure. I looked around, and to me this answer shows the most promise in being simultaneously cross-platform and keeping things simple.

The gist of that approach is that possibly the most basic (and in many ways, the most accurate) way to profile/optimise is to simply sample the stack directly every now and then by halting execution... Unfortunately, NetBeans won't pause. So I'm trying to find out how to do this sampling with gdb directly.

I don't know a great deal about gdb. What I can tell from the man pages though, is that you set breakpoints before running your executable. That doesn't help me.

Does anyone know of a simple approach to getting gdb (or other gnu tools) to either:

  1. Sample the stack when I say so (preferable)
  2. Take a whole bunch of samples at random intervals over a given period

...give my stated configuration?

解决方案

Have you tried simply running your executable in gdb, and then just hitting ^C (Ctrl+C) when you want to interrupt it? That should drop you to gdb's prompt, where you can simply run the where command to see where you are, and then carry on execution with continue.

If you find yourself in a irrelevant thread (e.g. a looping UI thread), use thread, info threads and thread n to go to the correct one, then execute where.

这篇关于gdb:循环执行期间如何暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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