如何直观地描绘内存中的堆栈?

发布于 2024-12-12 08:47:51 字数 615 浏览 0 评论 0原文

这是一个由两部分组成的问题:

  1. 我想知道是否有人知道有任何免费的工具/应用程序来设计内存堆栈的可视化应用程序?其中包括堆栈信息(例如堆栈指针、返回地址、变量、帧指针...)。我听说 Multi(Green Hills)可能会这样做,但是当我检查他们的网站时,他们似乎没有提供这样的功能。如果你想不出一个程序可以完成我所要求的任务,那么我将从你能找到的包含堆栈信息的最佳图像中受益(我在谷歌上搜索过“内存堆栈图像”,但它们都非常不同)寻找)。

  2. 我对 C 编程语言完全陌生,正在尝试执行上述操作。因此,我的第一个问题的结果是如何找到所有堆栈信息以将其转换为可视格式?我这样做是为了完成一项课堂作业,并且相信 GDB 可能能够完成这个任务。我仍在学习如何使用 GDB(已经阅读了一些指南),所以如果有人知道如何使用它来查找程序中执行的每个步骤的所有变量、返回地址、指针等每个堆栈帧,那就太棒了。如果您知道另一个可以简单地完成此任务的工具,那么我很愿意了解它以及如何使用它。

非常感谢!

注意:我在该网站上发现了一些类似的问题,但其中一些问题要么没有得到解答,要么得到了模糊的答复。我希望有人能花几分钟详细解释一下,特别是问题 2。

操作系统:Linux (Ubuntu) 编程语言:C

This is a two-part question:

  1. I was wondering if anyone knew of any FREE tools/applications to design visual applications of memory stacks? Of which would include stack information (e.g. stack pointers, return addresses, variables, frame pointers...). I've heard Multi (Green Hills) might do this, but when I've checked their website it didn't seem as if they offered such a feature. If you can't think of a program that can do what I'm asking, then I would benefit from the best image you can find that includes stack information (I've Googled "memory stack images," but they are all very different looking).

  2. I'm completely new to the C programming language and am trying to do the above. As such, a consequence of my first question is how do I find out all the stack information for me to put into a visual format? I'm doing this for a class assignment and believe that GDB might be able to accomplish this. I'm still learning how to use GDB (have read a couple of guides already), so if anyone knows how to use it to find out all the variables, return addresses, pointers, and so forth for each step in a program executing through each stack frame, that would be awesome. If you know another tool that can accomplish this simply however, then I'd be open to hearing about it and how to use it.

Thanks so much!

Note: I found some similar questions addressed on this site, but must of them either weren't answered or were vaguely answered. I hope someone out there has a few minutes to detail an explanation, particularly for question 2.

Operating System: Linux (Ubuntu)
Programming Language: C

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

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

发布评论

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

评论(1

猛虎独行 2024-12-19 08:47:55

有几点:

  • 基本上,您需要一种方法来遍历堆栈,
  • 这非常依赖于平台,并且取决于您正在使用的操作系统和硬件平台。看起来你正在使用linux。对于Windows,有可用的本机API
  • ,我假设这是针对C程序的,因此您需要了解C调用约定(参数如何放在堆栈上,返回地址存储在哪里等等此外
  • 可能还有其他额外的内容)如果 ASLR 处于活动状态,则存在一些困难
  • 。其中之一是

[http://pages.cs.wisc.edu/~bart/DynStackwalker.pdf][1]。

A couple of points:

  • Basically you need a means to walk the stack
  • This is very platform dependent and it depends on the os and the hardware platform you are using. It looks like you are using linux. For windows there are native API's available
  • I assume this is for c programs, so you need to understand the C calling conventions (how are the parameters are put on the stack, where the return address is stored and so on
  • In addition there might be additional difficulties if ASLR is active.
  • For linux several APIs exist. One of them is

[http://pages.cs.wisc.edu/~bart/DynStackwalker.pdf][1]

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