如何获取GDB中的物理地址?

发布于 2024-12-08 09:40:44 字数 395 浏览 0 评论 0原文

操作系统阻止 GDB 向我们提供物理地址,因此我们有虚拟地址。 有没有办法真正获得该物理地址?

在 Windows Visual Studio 上进行调试看起来更有希望:地址看起来更像真实地址。然而,它们真的是物理地址吗???

我已经用下面的源代码研究 GDB 和 Visual Studio 几天了(你可以从我的个人资料中看出这一点)

int main()
{
  int a = 10;
  int b = 13;
  int c;
  c = a + b;
  return 0;

}

PS:我知道我一直在问很多类似的问题。这是一个非常广泛的主题,我感谢你们所有的大力帮助。 JFYI,现在是凌晨 3:36 :( 在我来这里询问之前我做了很多研究+测试。 谢谢。

OS prevents GDB from giving us the physical address, and instead we have virtual addresses.
Is there a way to actually get that physical address?

Doing debugging on Windows Visual Studio looks more promising: the addresses look more like real addresses. However, are they really the physical addresses???

I have been investigating GDB and Visual Studio with the following source code for a few days already (and you can tell this from my profile)

int main()
{
  int a = 10;
  int b = 13;
  int c;
  c = a + b;
  return 0;

}

PS: I know I have been asking many similar questions. This is a super broad topic, and I thank you all the great helps. JFYI, it is 3:36AM :( and I do a lot of research + testing before I come here to ask.
Thanks.

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

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

发布评论

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

评论(3

惟欲睡 2024-12-15 09:40:44

如果您指的是物理内存硬件上的实际地址,那么实际上并不存在这样的事情(考虑操作系统可能决定将页面交换到磁盘等)。

请参见此处:如何将虚拟内存地址转换为物理地址?

If you mean the actual address on the physical memory hardware, then there isn't really such a thing (consider that the OS may decide to swap your page to disk, etc.)

See here: How to translate a virtual memory address to a physical address?

酒绊 2024-12-15 09:40:44

你不能,程序和gdb根本不知道它,这就是虚拟化内存的要点。操作系统负责根据需要将足够大的块分配给程序。

You can't, the program and gdb simply don't know about it, which is the point of virtualizing the memory. The operating system takes care of distributing large enough chunks to programs on demand.

偏闹i 2024-12-15 09:40:44

如果您为操作系统编写内核模式驱动程序,您将能够从其内部找到物理地址。但这很可能不切实际(编写这样的驱动程序并不容易,地址可能会因交换而改变,并且仅知道地址可能也没有用)。

If you write a kernel-mode driver for the OS, you'll be able to find out the physical addresses from inside of it. But this most likely isn't practical (it's not easy to code such a driver, the addresses can change due to swapping, and just knowing the addresses is probably of no use either).

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