堆栈指针的打印出价值 [英] Print out value of stack pointer

查看:191
本文介绍了堆栈指针的打印出价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在Linux操作系统(Debian和Ubuntu)?在C堆栈指针打印出当前值

How can I print out the current value at the stack pointer in C in Linux (Debian and Ubuntu)?

我试图谷歌,但没有发现任何结果。

I tried google but found no results.

推荐答案

一招,这是不可移植或真的连保证正常工作,就是简单的打印出本地的一个指针的地址。

One trick, which is not portable or really even guaranteed to work, is to simple print out the address of a local as a pointer.

void print_stack_pointer() {
  void* p = NULL;
  printf("%p", (void*)&p);
}

这将从根本上打印出 P 的地址,这是当前堆栈指针的一个很好的近似

This will essentially print out the address of p which is a good approximation of the current stack pointer

这篇关于堆栈指针的打印出价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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