如何在totalview中查看源代码?

发布于 2024-09-10 10:08:37 字数 190 浏览 6 评论 0原文

我刚刚在我的“hello world”应用程序(c++)上启动了totalview,我只能查看汇编代码。

我需要设置任何设置/标志才能查看源代码吗?菜单栏->视图->源作为->源对我不起作用。

我尝试调试的应用程序只是一个 cout << “Hello World”应用程序,只是为了让调试器启动并运行。

I just fired up totalview on my "hello world" application (c++) and i only get to view the assembly code.

Is there any settings/flags i need to set to view the source code? Menubar->View->Source As->Source does not work for me.

the application im trying to debug is just a cout << "Hello World" application, just to get the debugger up and running.

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

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

发布评论

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

评论(2

相权↑美人 2024-09-17 10:08:37

让我们从简单的事情开始。

您是否使用“-g”调试标志编译应用程序?调试器依赖编译器为其提供符号表和行号表,以将可执行文件中发生的情况映射回源代码。如果没有 -g 标志(或者如果您随后剥离应用程序),该信息将不会出现,并且汇编调试是您所希望的最好结果。

如果您确实使用 -g 进行编译,则源代码和可执行文件都位于同一目录中,或者如果没有,那么自您编译它们以来它们是否已被移动?编译器只知道源代码和可执行文件在创建时的位置,如果您移动它们,那么有时调试器将无法找到源代码文件。在这种情况下,您可能需要通过定义源代码搜索路径来为其提供一些帮助。

写回这里,让我知道 -g 是否解决了您的问题。如果没有,我们可以查看搜索路径等。

干杯,
克里斯

Lets start with the simple stuff.

Did you compile your application with the '-g' debugging flag? The debugger relies on the compiler to provide it with a symbol table and line number table to map what happens in the executable back to your source code. Without that -g flag (or if you subsequently strip your application) that info won't be present and assembly debugging is the best you can hope for.

If you did compile with -g are the source and the executable all together in the same directory, or if not have they been moved since you compiled them? The compiler only knows the locations of the source and executable at the time they are created, if you move them around then sometimes the debugger won't be able to locate the source code file. In that case you might need to give it some help by defining a source code search path.

Write back here and let me know if -g fixed your problem. If not we can look into the search path and such.

Cheers,
Chris

漫漫岁月 2024-09-17 10:08:37

我意识到 Jason94 几乎肯定已经用其他方式解决了他的问题,但我想我可以在这里插话来回答这个问题,因为这是一个很好的问题。

对于这种特殊情况,了解程序是否是多线程的会很有趣。 TotalView 旨在让您使用多线程程序,它具有一个可能令用户感到惊讶的特性。默认情况下,它不会总是将您的注意力集中在遇到断点的线程上。因此,您的程序实际上可能已停止在另一个线程中的第二个断点处。

假设您有 6 个线程(我们将它们编号为 0 - 5),并且您在例程中设置了一个断点。线程 0 是您关注的线程,您点击“开始”。程序运行,线程 4 首先命中断点。默认情况下,当断点被击中时,断点将停止整个过程。在调试器中,您可能会看到代表线程 4 命中断点时线程 0 所在位置的程序集。
您可以检查根窗口或线程窗格以查看其他线程的状态,您可能会看到其中一个线程显示“B2”(对于断点 2)。然后您可以单击该线程,TotalView 会将您重新聚焦到该线程,您将看到它位于断点处。

我们为什么要这么做?好吧,因为我们认为仅仅因为另一个线程遇到断点而让您的注意力“从您身上夺走”是令人困惑/不安的。因此,默认情况下,我们让用户控制他们的线程焦点。

您可以更改一个首选项,该首选项将告诉 TotalView 将流程窗口重新聚焦到“事件站点”。如果您希望 TotalView 将您的注意力重新集中到断点上,您可以进行设置,但请注意,当您这样做时,您可能会从一个线程跳到下一个线程。

另一种可能性是 TotalView 由于断点以外的某种原因停止了该进程。程序有段错误吗?检查进程窗口顶部的状态栏,查看线程和进程的状态。

不管怎样——只是想把这个贴出来作为记录。

I realize that Jason94 has almost certainly solved his problem some other way, but I figured I could chime in here to answer this since it is a good question.

For this particular case it would be interesting to know if the program is multi-threaded. TotalView is designed to let you work with multi-threaded programs and it has a characteristic that may be surprising to users. By default it won't always focus you on the thread that hits the breakpoint. So your program might actually have stopped at your second breakpoint in another thread.

Imagine you have 6 threads (we'll number them 0 - 5) and you set a breakpoint in a routine. Thread 0 is the one you are focused on and you hit "go". The program runs and thread 4 hits the breakpoint first. By default the breakpoint will stop the whole process when the breakpoint is hit. In the debugger you might see assembly representing where thread 0 was when thread 4 hit the breakpoint.
You can check the root window or the thread pane to see what the status of the other threads are and you might see that one of them says "B2" (for breakpoint 2). Then you can click on that thread and TotalView will refocus you to that thread and you'll see it sitting at the breakpoint.

Why do we do that? Well, because we think it is confusing/disconcerting to have your focus "ripped away from you" just because another thread hit a breakpoint. So by default we leave the user in control of their thread focus.

There is a preference that you can change which will tell totalview to refocus the process window to the "site of the event". You can set that if you would prefer to have TotalView refocus your attention to the breakpoint, but be aware that as you do that you may be bouncing from one thread to the next.

The other possibility is that TotalView stopped the process for some reason other than a breakpoint being hit. Did the program segfault? Check the status bar at the top of the process window to see what the status of the thread and process are.

Anyway -- just wanted to post this for the record.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文