如何用GDB在给定函数的范围内声明一个变量? [英] How to declare a variable in the scope of a given function with GDB?

查看:176
本文介绍了如何用GDB在给定函数的范围内声明一个变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道gdb允许已经声明的变量用 set 命令设置。



gdb是否可以在给定函数的作用域内动态声明一个新的变量?

对于C(也可能是C ++)代码,这将非常困难,因为在大多数实现中这样做会涉及到移动堆栈指针,这将导致函数的退出代码失败,因为它不再匹配堆栈帧的大小。同样,访问局部变量的函数中的所有代码都会突然冒险出现错误的位置,这也是不好的。

所以,我不这么认为,不。

I know that gdb allows for an already declared variable to be set using the set command.

Is it possible for gdb to dynamically declare a new variable inside the scope of a given function?

解决方案

For C (and probably C++) code, that would be very hard, since doing so in most implementations would involve shifting the stack pointer, which would make the function's exit code fail due to it no longer matching the size of the stack frame. Also all the code in the function that accesses local variables would suddenly risk hitting the wrong location, which is also bad.

So, I don't think so, no.

这篇关于如何用GDB在给定函数的范围内声明一个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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