如何在不痛苦地进行类型转换的情况下评估GDB中的功能?

编程入门 行业动态 更新时间:2024-10-28 01:23:19
本文介绍了如何在不痛苦地进行类型转换的情况下评估GDB中的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在如何在GDB中评估函数的答案?我找到了在程序外部调用函数的方法在GDB中被称为floor,如下所示:

In an answer to How to evaluate functions in GDB? I found the recipe to call a function outside of my program called floor from within GDB like this:

(gdb) p floor $20 = {<text variable, no debug info>} 0x38e10197b0 <floor> (gdb) p ((double(*)(double))floor)(2.9999) $21 = 2 (gdb) p ((double(*)(double))floor)(2.000001) $22 = 2 (gdb)

我需要做些什么,短是编译器升级,目前对我来说这不是 的选项,以便我可以在我将在原始C/C ++文本文件中执行的相同方法,例如:

What do I need to do, short of a compiler upgrade which is not an option for me at the moment, in order for me to call the function in the same manner in which I would do inside the original C/C++ text file, e.g.,:

p floor(2.9999)

具体来说,我想不必必须打开floor上的手册页以找到功能签名:

Specifically, I would like to not have to open up the man page on floor to find the function signature:

double floor(double x);

然后编写表达式以馈送给gdb的print命令,该命令是使用double返回double并带有大量括号的指针.

and then concoct an expression to feed to gdb's print command that is a pointer taking a double returning a double, with lots of parentheses.

那么,这是我们在GDB中调用这些类型的低级函数的唯一方法吗?还是我想念的东西?是因为我根本没有加载某种类型的调试符号"或类似的东西吗?上面输出中的参考文献no debug info使我相信,我的机器可能缺少用于调试符号"的软件包或与之等效的软件包,这些软件包可以让我用本机C或C ++表示出来?

So, is this the only way for us to call these types of low level functions in GDB? Or is there something I'm missing? Is it because I simply don't have some type of "debug symbols" loaded or something like that? Reference no debug info in the output above that leads me to believe that perhaps my machine is lacking some package for "debug symbols" or the equivalent that would allow me to express this in the native C or C++?

这是专门针对Linux的.我对平台无关的答案不感兴趣,因为它们与我的用例无关(尽管一般而言,仅针对此问题).

This is specifically for Linux. I'm not interested in platform-agnostic answers as they are irrelevant in my use-case (not in general, though, just for this question).

推荐答案

我需要做什么

What do I need to do

您应该为libc安装libc6-dbg或类似的调试符号软件包(floor在libm中,它是GLIBC的一部分).

You should install libc6-dbg or similar package of debugging symbols for libc (floor is in libm, which is part of GLIBC).

没有调试符号,GDB不知道floor是什么类型.

Without debug symbols, GDB has no idea what the type of floor is.

更多推荐

如何在不痛苦地进行类型转换的情况下评估GDB中的功能?

本文发布于:2023-10-09 02:14:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474417.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   类型   功能   如何在   不痛苦

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!