简体   繁体   English

如何在nsight eclipse版本中查看变量值

[英]How do I view variables values in nsight eclipse edition

I'm using nsight eclipse edition, and I cant figure out how to view variables values in debug mode for now (meaning usual variables in host memory, debugging usual c++ code so far). 我正在使用nsight eclipse版本,我现在无法弄清楚如何在调试模式下查看变量值(意味着主机内存中的常用变量,到目前为止调试常用的c ++代码)。 "Variables" tab does not contain anything useful for me (nothing I can use now at least), and Memory tab, which should be able to display variables by their addresses and also monitor expressions does not work for me either. “变量”选项卡不包含对我有用的任何内容(至少我现在无法使用),而Memory选项卡应该能够通过地址显示变量并监视表达式也不适用于我。

Any suggestions? 有什么建议么?

The following steps seemed to work for me: 以下步骤似乎对我有用:

  • open nsight 开放的
  • create a new project, select CUDA C/C++ project, and select CUDA Runtime project 创建一个新项目,选择CUDA C / C ++项目,然后选择CUDA Runtime项目
  • the project will be populated with a simple "bitreverse" code. 该项目将填充一个简单的“bitverse”代码。 The initial configuration will be the debug configuration. 初始配置将是调试配置。 Select Project...Build Project to build the sample code (debug version). 选择Project ... Build Project来构建示例代码(调试版本)。
  • Now on the right hand side of the toolbar, press the "Debug" button, to switch to the Debug perspective. 现在位于工具栏的右侧,按“Debug”按钮,切换到Debug透视图。
  • on the left of the first CUDA_CHECK_RETURN(...) line of code, right click and select "Toggle Breakpoint" to set a breakpoint at that line of code. 在第一行CUDA_CHECK_RETURN(...)代码行的左侧,右键单击并选择“Toggle Breakpoint”以在该行代码处设置断点。
  • select Run...Debug The program will then be started in debug mode, stopped at the first line of code, and the host variables will be filled in in the upper right hand corner "Variables" pane. 选择Run ... Debug然后程序将以调试模式启动,在第一行代码处停止,主机变量将填入右上角的“Variables”窗格中。
  • To the left of the idata variable, select the triangle to expand the sub-menu. idata变量的左侧,选择三角形以展开子菜单。 The submenu is populated with the values of idata at each index. 子菜单使用每个索引处的idata值填充。 The data will be garbage, as it has not been initialized yet. 数据将是垃圾,因为它尚未初始化。
  • Select Run...Resume to continue program execution. 选择Run ... Resume继续执行程序。 Program execution will halted at the breakpoint previously set. 程序执行将在先前设置的断点处暂停。
  • If we inspect the idata variable in the "Variables" pane, we see that the values have been changed (initialized) to 0, 1, 2, ... etc. 如果我们检查“变量”窗格中的idata变量,我们会看到值已被更改(初始化)为0,1,2,...等。

If you attempt to debug a project for which you have built the "Release" configuration instead of "Debug" configuration, you will have a variety of issues, and will get a message "no source available" and there will be no variables displayed in the "Variables" pane. 如果您尝试调试已构建“发布”配置而不是“调试”配置的项目,则会出现各种问题,并且会收到“无可用源”消息,并且不会显示任何变量“变量”窗格。

I was using gcc 4.8, which caused problems. 我使用gcc 4.8,这导致了问题。 Now I downgraded to gcc 4.6 and it solved problem. 现在我降级到gcc 4.6,它解决了问题。

Robert Crovella, thanks for your effort. Robert Crovella,谢谢你的努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM